[jQuery] Re: Why doesn't code execute when Drop Down is changed or Button clicked.

2008-11-24 Thread Liam Potter


try

$(#clickMe).click(function () {
  alert('four');
});



bkbonner wrote:

I've been trying  to figure out why when I click the button nothing
happens...Can someone shed me some light on this example?

html

head

script src=jquery-1.2.6.min.js/script   
script 
function init(){
alert('one');
alert('two');
};

$(init);

$(#lstRace).change(
   alert('three');
);

$(#clickMe).click(
   alert('four');
);

/script
/head
body
Hello

select id=lstRace name=lstRace 

option value=1Test/option
option value=2/Test3/option
option value=3/Other, please specify/option
/select


input type=test id=raceOtherDiv name=other /
input type=button id=clickMe click me /input
/body
/html
  




[jQuery] Re: Why doesn't code execute when Drop Down is changed or Button clicked.

2008-11-24 Thread ricardobeat

Also you need to add the handlers after DOM has loaded, or run the
script at the end of the document body:

script type=text/javascript
$(document).ready(function(){

$('#lstRace').change(function(){
  alert('yay');
});

   // everything that deals with elements in here

});
/script

Sounds like you're starting in Javascript via jQuery, that's not the
wisest choice. Try learning the basics of Javascript before tackling
jQuery, that will make things a lot easier for you.

cheers,
- ricardo
On Nov 24, 11:16 am, Liam Potter [EMAIL PROTECTED] wrote:
 try

 $(#clickMe).click(function () {
            alert('four');
         });

 bkbonner wrote:
  I've been trying  to figure out why when I click the button nothing
  happens...Can someone shed me some light on this example?

  html

  head

  script src=jquery-1.2.6.min.js/script          
  script 
     function init(){
         alert('one');
         alert('two');
          };

          $(init);

          $(#lstRace).change(
             alert('three');
     );

          $(#clickMe).click(
             alert('four');
     );

  /script
  /head
  body
  Hello

  select id=lstRace name=lstRace 

  option value=1Test/option
  option value=2/Test3/option
  option value=3/Other, please specify/option
  /select

  input type=test id=raceOtherDiv name=other /
  input type=button id=clickMe click me /input
  /body
  /html