assign value of html textbox to title of div

前端 未结 1 1278
天涯浪人
天涯浪人 2021-01-28 06:37

line 1:


line 2:



        
相关标签:
1条回答
  • 2021-01-28 07:08

    Your question is all over the place - the question / HTML / JavaScript dont match up .... below is a way to update the href and text of an anchor (not a div) on the click of a button

    <input id="Text1" type="text" /><input id="Button1" type="button" value="button" /><br />
    <a id="Link1" target="_blank" href="http://search.twitter.com/search?q=#msdhoni">#msdhoni</a>
    

    JavaScript :

    $('#Button1').click(function() {
        $('#Link1').attr('href',"http://search.twitter.com/search?q=#" + $('#Text1').val());
        $('#Link1').text("#" + $('#Text1').val());
    });
    

    Note: You need to add an ID to the anchor to make this code work

    0 讨论(0)
提交回复
热议问题