开发者

Jquery code not running on test site [duplicate]

开发者 https://www.devze.com 2023-02-10 07:31 出处:网络
This question already has answers here: Why is this jQuery click function not working? (9 answers) Closed 5 years ago.
This question already has answers here: Why is this jQuery click function not working? (9 answers) Closed 5 years ago.

Here is the sample of code that I've concentrating on. I've tried to incorporate it with my test site and the code doesn't work. I don't understand why, in both instances I'm using the latest version of Jquery (1.5) I'm using Google's hosted Api for my test site.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>

<script>
  $('#name-label').dblclick(function() {
    $("#name").val('some text');
  });
</script>

<div class="ctrlHolder">
  <label for="" id="name-label">开发者_运维技巧;Name</label>
  <input name="name" id="name" type="text" class="textInput small" />
  <p class="formHint">The name of the item you are submitting</p>
</div>


Does wrapping it in a $(document).ready(function() {}); work?

$(document).ready(function() {
    $('#name-label').dblclick(function(){
        $("#name").val('some text');
    });
});


$(function() {
  $('#name-label').dblclick(function(){
      $("#name").val('some text');
  });
}
0

精彩评论

暂无评论...
验证码 换一张
取 消