开发者

JQuery - What can I do to make this work?

http://jsfiddle.net/piezack/X8D4M/5/

I need the change created by clicking the button to be detected.开发者_JAVA百科 At the moment you have to click inside the field and then outside for it to detect any change.

Thanks guys.

The code for the button CANNOT be altered. Good tries so far though.

Was overcomplicating things. Answer http://jsfiddle.net/piezack/X8D4M/56/


Example using trigger:

//waits till the document is ready
$(document).ready(function() {

    $('button.butter').click(function() {
        var $form6  = $('#FormCustomObject6Name');
        $form6.val('Text has changed');
        $form6.trigger('change')
    });

    $('#FormCustomObject6Name').change(function() {
        var x = $('#FormCustomObject6Id').val();

        $("a").filter(function() {
            return this.href = 'http://www.msn.com'
        }).attr('href', 'http://www.google.com/search?q=' + x);
        alert(x);
    });

});


i think that jmar has the right idea...if i understand correctly you want to be able to type whatever in the box and without clicking out of it to have the button change it to the text has changed.

i dont know if that alert is really necessary, but you can do this if the alert is not needed:

http://jsfiddle.net/X8D4M/24/


To trigger the change event simply add a .trigger after setting the value.

Also, you're selector for the link wasn't working so I just changed it to #link.

http://jsfiddle.net/X8D4M/22/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜