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