Custom placeholder inside element <td> not showing
This question already has an answer here:
The only problem i see is the new lines: when you need to continue on the next line you need to escape the new line char like in:
var str = '11111
llllllll';
The snippet:
$(function () {
$("#addbutton").click(function() {
$('#searchresults > tbody:last-child').append('<tr><td><div contentEditable="true" data-text="Enter Name"></div></td>
<td><div contentEditable="true" data-text="Enter Description"></div></td>
</tr>');
});
});
[contentEditable=true]:empty:not(:focus):before{
content:attr(data-text)
}
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<button id="addbutton">addbutton</button>
<table id="searchresults">
<tbody>
</tbody>
</table>
$("#addbutton").click( function(){
$('#searchresults > tbody:last-child').append('<tr><td> <div contentEditable="true" data-text="Enter Name"></div> </td>
<td><div contentEditable="true" data-text="Enter Description"></div></td>
</tr>')
There was a space between <td> <div>
as seen above. Someone edited the question and removed it.
Please do not edit questions at your own whim. Apparently adding space in can screw things up !
链接地址: http://www.djcxy.com/p/30456.html上一篇: MySQL的“WITH”子句
下一篇: 元素<td>内的自定义占位符未显示