I am new in JQuery and having problem in getting element from HTML.
4 回答
If I understood correctly you need the context part of jQuery()
function:
// string with HTML content
var content = '<div><p class="myel">Test</p></div>';
// returns '<p>' element
var myEl = $(".myel", content);
$("#id").html() or $("#id").text();
"#" is used for id
. is used for class
<div id="id">this is text</div>
Although this question is rather vague I'll take a stab at understanding your issue anyway,
You can retrieve any HTML element as an object in jquery
simply by referencing it in any number of ways that is possible in jquery
.
i.e
if you have a div
with an id
of noodles
( <div id="noodles"></div>
) you can reference it in jquery with something like
myHTMLelement = $('#noodles').html();
or if you want the html as plain text you can do the following
myHTMLelement = $('#noodles').text();
Just use $(this is the parent of element).find(expected element). just like as
$(div).find(table)
see this link