mardi 25 septembre 2018

javascript extract substring from checkbox innput string value

below a set of checkbox, I would like to retrieve the monetary value of the string from the box to consistent.

for example if the checkbox input value is "Vantaux inegaux maxi vantail 2150 mm $1021.2" i would get the 1021.2 .

here is my code but it returns an error when using .val()

Uncaught TypeError: this.checked.val is not a function

checkbox values

$(document).ready(function() {
  $('input[type=checkbox]').change(function() {
    if(this.checked) {
      console.log (this.checked.val());
    }
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" value="Vantaux inegaux maxi vantail 2150 mm $1021.2"/>

any suggestion please ?




Aucun commentaire:

Enregistrer un commentaire