nicola10 Posted September 26, 2018 Share Posted September 26, 2018 Hello I would like to insert into a span tag the label of a radio button on checked status but It doesn't works and not showing errors I'm trying the following code to test in the change function works property. Variables like name, id and value are recovered correctly but the content of tag span doesn't change <script> $(document).ready(function() { $('input[name="InputName" value="InputValue" id="InputID"]').change(function() { var value = $("input[name='InputName']:checked").val(); $('#SpanID').text(value); }); }); </script> Any solution? Link to comment Share on other sites More sharing options...
nicola10 Posted September 26, 2018 Author Share Posted September 26, 2018 Changing the controls and the event associated the id of the checked radio button is inserted into the content of span tag. But I do not know how to insert the option label and if I click another option, I have to double-click to update the content $('label').click(function() { var value = $("input[name='InputName']:checked").val(); $('#SpanID').text(value); }); Link to comment Share on other sites More sharing options...
nicola10 Posted September 26, 2018 Author Share Posted September 26, 2018 To get the label I changed from var value = $("input[name='InputName']:checked").val(); to var value = $("input[name='InputName']:checked").next().text(); But when I change the selection I have to click 2 times to see the updated content into the span tag Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now