I am using JQuery to dynamically add a new row to a table.
I would like to have a placeholder inside the table cells that go away when the user clicks to enter text.
I attempted to make CSS that would do this.
Here is the JQuery:
$("#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>')
Here is the CSS:
<style>
[contentEditable=true]:empty:not(:focus):before{
content:attr(data-text)
}
</style>
The placeholder text isnt showing up.
Any suggestions ?
Ive updated the question so that the new line is correctly spliced in the string inside .append('')
I still cannot get the text to appear. I am using Safari on El Capitan. The new row is added and is editable but the text isnt there !
The rows get added and are also editable. Its just that the text is not visible.