我面临动态添加链接的问题。
HTML
<button class="click-me">Click me</button>
<br><br><br>
<div class="dyanmic-link"></div>
JQuery的
//Embedding a link dynamically
$('.dyanmic-link').html("<a href='www.google.com' class='dynamic-link'>Click Dynamically </a>");
//Click on a button
$('.click-me').click(function(){
$('.dynamic-link').click(); //Not working
$('.dynamic-link').trigger( "click" ); //Not working
});
JSfiddle: - https://jsfiddle.net/e9ue227c/30/
答案 0 :(得分:2)
bitbake -c cleansstate phytec-headless-image
bitbake -c clean phytec-headless-image
bitbake phytec-headless-image
不能直接处理jQuery包装的锚点。在触发点击之前,您需要拔出native DOM object。替换这个:
click()
用这个:
$('.dynamic-link').click(); //Not working