子页面元素是通过父页面的iframe进来的,所以在子页面元素需要获取父页面的元素做一些改变。
jquery就为我们提供了一个很好的方法 :
第一、在iframe中查找父页面元素的方法:
$(’#父页面元素id’, window.parent.document);
$('#tmenu',window.parent.document).append("<li class='tmenuli'>“)
第二、在父页面中获取iframe中的元素方法:
$(this).contents().find("#suggestBox")
第三、在iframe中调用父页面中定义的方法和变量:
parent.method parent.value