1.JS实现: var object= window.parent.frames("要获得的iframe的name").contentDocument.getElementById("元素id"); 2.jquery实现: var object =$( "元素id", window.parent.frames("iframe的name").contentDocument); iframe获得父页面指定id的元素的方法: var
在开发jquery时候经常需要用到定位,有相对父元素定位和相对文档定位,本文为此总结下,有需要的朋友可以参考下 在开发jquery时候经常需要用到定位,这里概括两种定位: 1.相对父元素定位: $("#ele").position(),进而得到 left = $("#ele").postion().left right = $("#ele").postion().right2.相对文档定位:$("#ele").offset()
方法一. window.onload=function(){ //寻找对象在父元素下的index function getIndexParent(element){ var oParent=element.parentNode; var oElement=oParent.children; for(var i=0;i<oElement.length;i++){ oElement[i].index=i
无意间在实现元素垂直居中的一种方式测试到,当一个元素高度没有指定的情况下,其 postion:relative;top:-50%;无效 后来查阅w3c看到这样一句话: <percentage> 百分比 The offset is a percentage of the containing block's width (for 'left' or 'right') or height (for 'top' and 'bottom'). For 'top' and 'bottom', if th