change the value of the input element

Posted by Lina on Stack Overflow See other posts from Stack Overflow or by Lina
Published on 2010-04-27T14:42:21Z Indexed on 2010/04/27 14:43 UTC
Read the original article Hit count: 148

Filed under:

Hi, the following code is costing me a lot of precious time, can anybody help me on this??

<div id="i">
    <input id="Text1" type="text" value="hello" onClick="hello();"/>
</div>

<script>
    function hello() {
        var x = $("#i").html();
        var y = $(x).val();
        alert(y);
    }
</script>

in the case above the word "hello" is alerted each and every time, what if i want to alert the user input??? i.e. how do i change the "value" attribute of the input field???? thanks a trillion

© Stack Overflow or respective owner

Related posts about jQuery