Javascript libraries + JQuery plugins contradict? How to debug?

拜拜、爱过 提交于 2020-01-06 15:48:27

问题


This is somewhat a newbie question... I effort everyday to learn, so please understand ;) I'm not the very best expert, but I can do a decent job good looking and functional websites or web applications. My main tools are PHP5, HTML5, CSS2 y 3, a database (SQLite, MySQL) and Javascript and JQuery.

I'm not an expert at all in Javascript. I often find interesting JQuery plugins or tutorials and try to mix them up to do the functionality needed. This time I'm mixing maybe too much plugins and js files from different sources.

In fact, my app do what I want except for certain behaviors... There are no errors, everything looks fine, but the misbehavior persists. So maybe I need to specify a class I don't know about, or one contradicts another one from another plugin and I just can't understand, for example, why a <button type="button">DON'T submit</button> just submits the form...

Anyway, my point is: Do you people know a way to debug this situations??? Is there a generic tool, suggestion, workflow or something to help me understand conflicts or omissions between libraries or plugins??? (Javascript libraries, my own Javascripts and JQuery plugins)???

EDIT: I know about Chromes debugger and FireBug... But maybe I just don't know how to get the functionality I need... Reading about how to use these tools haven't helped me... For example: I've got a tag which has inherit a class I didn't assigned it to by hand (example: <button type="button" disabled>DON'T submit</button> I didn't write disabled by myself) So some Javascript file it's assigning it, but how con I see WHO did this? Wich file? Class? Plugin? Library? Etc? That's another example of what I mean to ask =)

I hope it is a way! THANKS A LOT FOR YOUR HELP AND COMPREHENSION! =)


回答1:


It is possible that you're using two libraries that use the $() function. In jQuery, the $() function is just shorthand for jQuery(), so you could try taking your jQuery code and replacing every instance of "$(" with "jQuery(" and see if that helps out. Without know what scripts you're using I can't tell if that will work or not, but this is likely the problem if you have more than one framework (e.g. jQuery) loaded at one time.

Just make sure you don't change any non-jQuery functions from $() to jQuery() or else they'll break.




回答2:


The default functionality of the <button> tag is the same as <input type="submit">.

http://htmldog.com/reference/htmltags/button/




回答3:


Yes, there are tools to debug javascript.

Chrome as inbuilt debugger (Press F12 to open it)

But my favourite is firebug (its an addon for firefox, download it from here)

To resolve the conflicting issue, read here

Also, by default <button> submits the form.

If you do not want <button> to submit form, you can use this,

<button type="button" onclick='return false;'>DON'T submit</button>


来源:https://stackoverflow.com/questions/10837630/javascript-libraries-jquery-plugins-contradict-how-to-debug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!