Thursday, 5 September 2013

Manupulating DOM element using JAVA script or jquery

Manupulating DOM element using JAVA script or jquery

I am just new learner in java script, I was going through DOM manipulation
in java script or jquery
i was trying to catch the 'p' tag which was in my java script variable but
does not work can someone please do the necessary correction.
Answer can be given using java script or jquery both works for me
I also had some similar question here( Getting tags when whole HTML page
is in one javascript variable )[sorry for the confusing explanation in
this question]
W3Schools
<!DOCTYPE html>
<html>
<body>
<p>The DOM is very useful!</p>
<p>This example demonstrates the <b>getElementsByTagName</b> method.</p>
<script>
var myHTML ='<p>Hello World</p>'
x=myHTML.getElementsByTagName("p");
document.write("Text of first paragraph: " + x[0].innerHTML);
</script>
</body>
</html>

No comments:

Post a Comment