这些行在jquery中有什么区别? [英] What is the difference betweeen these lines of code in jquery?
本文介绍了这些行在jquery中有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我有一个div标签,其中包含内容为"I am div tag".当我尝试在用户单击按钮时切换此div时.这是我写的代码
Hi everyone ,I have a div tag which contains the Content as "I am div tag".When i was trying to Toggle this div when a user click on button. here is the code which i wrote
<
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>jquery effects (Hide,Animate,SlideDown,SlideUp)</title> <style type="text/css"> .togg { background-color: Aqua; } </style> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.js"> $(document).ready(function () { $("p").click(function () { $(".togg").toggle(); }); }); </script> </head> <body> <div class="togg"> I am a Div Tag <p> hi Laxmi ! how r u?</p> </div> </body>
>
在这里没有得到输出.但是当我编写这样的代码时,在这里得到了输出.请告诉我这些代码行之间的区别
am not getting the output here.But when i write the code like this here am getting the output.please tell me the difference between these lines of code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>jquery effects (Hide,Animate,SlideDown,SlideUp)</title> <style type="text/css"> .togg { background-color: Aqua; } </style> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.js"></script> <script type="text/javascript"> $(document).ready(function () { $("p").click(function () { $(".togg").toggle(); }); }); </script> </head> <body> <div class="togg"> I am div Tag <p> hi Laxmi! how r u?</p> </div> </body> </html>
推荐答案
(document).ready(function(){
(document).ready(function () {
("p").click(function (){
("p").click(function () {
(.togg").toggle();});}); & lt//script& gt; & lt;/head& gt; < body& gt; & lt; div class ="togg"& gt;我是Div标签& lt; p& gt;Laxmi! r u?/p& gt; & lt;/div& gt; & lt;/body& gt; & gt;
(".togg").toggle(); }); }); </script> </head> <body> <div class="togg"> I am a Div Tag <p> hi Laxmi ! how r u?</p> </div> </body> >
在这里没有得到输出.但是当我编写这样的代码时,在这里得到了输出.请告诉我这些代码行之间的区别
am not getting the output here.But when i write the code like this here am getting the output.please tell me the difference between these lines of code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>jquery effects (Hide,Animate,SlideDown,SlideUp)</title> <style type="text/css"> .togg { background-color: Aqua; } </style> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.js"></script> <script type="text/javascript">
这篇关于这些行在jquery中有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文