See you have missed #
notation for id selector and make sure to have it wrapped in $(function(){...})
doc ready handler:
$(function(){
alert($("#tab1").text());
alert($("#tab1").html());
});
Pregunta
I have a contenteditable div inside jquery tab and I am trying to get the content using a button. When I click on button a javaScript function is getting called, inside the function I am trying to grt the content
HTML code
<div id="tab1" contenteditable="true">
<div>line no one</div>
<div>line no one</div>
</div>
JavaScript function
alert($("tab1").text());
alert($("tab1").html());
error
For text(); I am not getting any thing but for html(); it is showing Undefined
I am not able to guess whats wrong with the code... Any suggestions...
Solución 2
See you have missed #
notation for id selector and make sure to have it wrapped in $(function(){...})
doc ready handler:
$(function(){
alert($("#tab1").text());
alert($("#tab1").html());
});
Otros consejos
jQuery expects a selector, not an id. "tab1"
is a type selector, it matches <tab1>
elements (which do not exist in HTML).
You can use an ID selector though: $("#tab1")
.
Are you using jquery?
Does it load proprely?
try this
alert($("#tab1").text());
alert($("#tab1").html());
you have to tell jquery that you are looking for an id with "#"