
Untitled
By: a guest on
May 2nd, 2012 | syntax:
None | size: 1.03 KB | hits: 11 | expires: Never
How to simulate on href with ref
<a href="javascript:void(0);" id="details" ref="1" title="|title" class="detail_button tips">
<a href="javascript:void(0);" id="MyId" title="title" >1</a>
<a href="javascript:void(0);" id="MyId" ref="1" title="title" >1</a>
<a href="javascript:void(0);" id="MyId1" ref="1" title="title" >2</a>
<a href="javascript:void(0);" id="MyId2" ref="1" title="title" >3</a>
<a href="javascript:void(0);" id="MyId3" ref="1" title="title" >4</a>
aElements = document.getElementsByTagName("a");
for (i = 0; i < aElements.length; i++) {
if (aElements[i].hasAttribute("ref") && aElements[i].hasAttribute("ref") == 1) {
aElements[i].onclick = function () {
alert(2);
}
}
}
document.getElementById('MyId').getAttribute('ref');
document.getElementById('MyId').onclick=function(){
var ref = this.getAttribute('ref');
//the ref is your value
if(ref == 1){
this.click();
}
}