Monday, August 20, 2012

javascript – How to select element based on another already-existing selector?

I have the following code:



<html>
<head>
<script src=\"http://www.google.com/jsapi\" type=\"text/javascript\"></script>
<script type=\"text/javascript\">
google.load(\"jquery\", 1);
</script>
<script type=\"text/javascript\">
var rt, rt2;
window.onload = function () {
rt = $(\'#rt\').contents().get(0);
rt.designMode = \'On\';
}
</script>
</head>
<body>
<iframe id=\"rt\" width=\"500\" height=\"500\"></iframe>
</body>
</html>


rt is currently selecting the whole iframe document. I want rt2 to select the body element inside the document element, which is what rt is selecting. I tried:



rt2 = jQuery(rt, \"html\");
rt2 = jQuery(rt2, \"body\");


But it didn\’t seem to work. How would it be possible?






Rating: 4 out of 5 based on 3 ratings



The post javascript – How to select element based on another already-existing selector? appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/javascript-how-to-select-element-based-on-another-already-existing-selector.html

No comments:

Post a Comment