大佬教程收集整理的这篇文章主要介绍了在div中调用javascript函数,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
到目前为止,我的页面如下所示:
<html> <head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> <script language="javascript" type="text/javascript" src="jquery-1.8.2.js"></script> </head> <body> <script type='text/javascript'> $( document ).ready( function() { // Draw all slots $('div.slot').each(function(i,d) { console.log('slot found: ' + d.id); // d.draw() does not work draw(); }); }); </script> <div class="slot" id="slot1"> <script type='text/javascript'> function draw() { console.log('Here we draw a circle'); }; </script> </div> <div class="slot" id="slot2"> <script type='text/javascript'> function draw() { console.log('Here we do something @R_728_10586@lly different and draw a rectangle'); }; </script> </div> </body> </html>
不幸的是我不知道如何调用所选div“d”的绘制函数.
现在它只调用最后定义的绘图函数.
更新:
请注意,我不能将不同的绘制方法组合成一个可以获得形状参数的方法.绘制方法将完全相互独立.
以上是大佬教程为你收集整理的在div中调用javascript函数全部内容,希望文章能够帮你解决在div中调用javascript函数所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。