jQuery live change problem

Posted by Milos on Stack Overflow See other posts from Stack Overflow or by Milos
Published on 2010-04-03T16:22:57Z Indexed on 2010/04/03 16:33 UTC
Read the original article Hit count: 327

Filed under:
|

When I click an element from list, jQuery get class from clicked element and write it in input field. Then value from input need to be written in div#content without any action.

HTML:

<ul>
    <li class="NewYork">New York</li>
    <li class="Paris">Paris</li>
    <li class="Moscow">Moscow</li>
</ul>

<input type="text" id="city" value="" />

<div id="content"></div>

jQuery:

$(document).ready(function() {
    $('ul li').live('click', function() {
        var select_value = $(this).attr('class');
        $('input#city').val(select_value);
        return false;
    });

    $('input#city').live('change', function() {
        var content = $(this).val();
        $('#content').text(content+' is beautiful city');
    });
});

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-ajax