Reputation: 67
<img style="cursor:pointer" class="optStyle"
src="/ekp/resource/style/default/icons/add.gif" title="添加行"
onclick="DocList_AddRow();XFom_RestValidationElements();">
I am using jQuery1.x selector to get the element, and then use its click function to make it, but it does not work in Internet Explorer, Chrome is ok.
$( "img[title='添加行']").click()
Here is the effect image link (I do not have 10 reputation so I can not post images) https://img.shownmmp.top/my.gif I have tried jquery1.x in ie console (f12), but it does nothing. I have done it in Chrome and it works very well, what should I do now?
I want the click function to work in ie. Also can you tell me how to make the img element clicked using javascript or jquery ? Thanks
Upvotes: 0
Views: 230
Reputation: 11335
I try to make a test with code below and find that it is working fine with IE 11 and chrome.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(document).ready(function(){
$("#clk").click(function(){
$( "img[title='添加行']").click();
});
});
function abc()
{
alert("abc");
}
function xyz()
{
alert("xyz");
}
</script>
</head>
<body>
<button id="clk">click</button>
<img style="cursor:pointer" class="optStyle"
src="C:\Users\Administrator\Desktop\plex-icon.png" title="添加行"
onclick="abc();xyz();">
</body>
</html>
Output in IE 11:
You can try to make a test with this code on your side and let us know whether it is working or not.
Upvotes: 1