0

I have a jquery click event setup:

$(".clickhere").click(function(){
    ...
});

I also have a span with an id of spanval.

<span id="spanval">1</span>

finally I have a form with an input...

<input id="spanvalue" name="spanvalue" value="whatever_the_value_of_the_span_is" />

So, what I need to do is the following:

If class of clickhere is clicked then get the text in the span and put it in the spanvalue's value.

1 Answer 1

9
$(".clickhere").click(function(){
    $('#spanvalue').val($('#spanval').text());
});

Live DEMO

Note that your's DOM elements naming is really really confusing... (spanvalue V.S. spanval)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.