javascript - Multiple buttns on a page - not working -


Can anyone tell me why the following is not working?

  & lt; Head & gt; & Lt; Script language = "javascript" src = "/ property / js / jazzery-1.3.2.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; $ ("Button"). Bind ("click", function () {warning ("you clicked" + $ (this) .attr ("id"));}; & Lt; / Script & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" /> & Lt; Title & gt; Untitled document & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Button ID = "Button 1" & gt; Click me! & Lt; / Button & gt; & Amp; Nbsp; & Lt; Button ID = "Button 2" & gt; Click me! & Lt; / Button & gt; & Amp; Nbsp; & Lt; Button ID = "Button 3" & gt; Click me! & Lt; / Button & gt; & Amp; Nbsp; & Lt; Button ID = "Button 4" & gt; Click me! & Lt; / Button & gt; & Amp; Nbsp; & Lt; Button ID = "Button 5" & gt; Click me! & Lt; / Button & gt; & Lt; / Body & gt;  

When I click on a button, nothing is happening.

Dave

Try:

  $ (Document) .ready (function () {$ ("button"). Bind ("click", function () {warning ("you clicked" + $ (this) .attr ("id"));} );});  

edit : As stated, using dam instead of live is even better Is when you have to apply the same function to more than 2 elements of the same type.
Follow the link for more information, credit for it.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -