I'm开发者_如何学运维 rather new to jquery so this may be the issue. I have a script that outputs several divs all with different text data in them. I would like it when I click one of them that an input field's value is updated to that text currently I have:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> 
<script type="text/javascript">   
$(document).ready(function() {
        $("a.results]").click(function() {
        data= this.text();
        $("#updateme").val(data);                                       });  
 });
 </script>
    <p>   <label>Field
        <input type="text" name="updateme" id="updateme">   </label> </p> 
<a href="#" class="results">Florida</a>
<a href="#" class="results">Florida 2</a>
<a href="#" class="results">Florida 3</a>
How can I make it so that whatever link is clicked that is the data that gets updated into the input's value? I can get it to take one or I can script out different cases of each changing the class name but I think there has to be a way where it references whatever link is being clicked instead of what it's currently doing.
Thanks in advance!
Try getting rid of your bracket: $("a.results]") - should be $("a.results"). That may help.
I think your solution is correct but there are some syntax errors. data= this.text(); should be var data = $(this).text() and $("a.results]") should be $("a.results")
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论