0
如何插入jQuery的HTML标记内使用它在onclick
。例如,我怎样才能在html中插入这个jquery函数?在html标签内使用jquery?
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("p").slideToggle();
});
});
</script>
</head>
<body>
<p>This is a paragraph.</p>
<button>Toggle between slide up and slide down for a p element</button>
</body>
</html>
你想要做什么?你现在的代码不工作吗? – JJJ 2012-03-24 14:07:09
您应该阅读一些jQuery教程:http://docs.jquery.com/Tutorials – 2012-03-24 14:15:55
使用内联事件处理程序会导致您网站的指数级难度维护,您应该*努力避免如果可能的话,并保持你的行为超出你的标记。 – 2012-03-24 14:22:50