-4

I am new in JQuery and having problem in getting element from HTML.

4

4 回答 4

1

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);
于 2012-09-29T08:05:23.947 回答
1
$("#id").html() or $("#id").text();

"#" is used for id 
. is used for class

<div id="id">this is text</div>
于 2012-09-29T08:05:51.850 回答
1

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();
于 2012-09-29T08:05:56.390 回答
1

Just use $(this is the parent of element).find(expected element). just like as

$(div).find(table)

see this link

于 2012-09-29T08:09:40.157 回答