samedi 6 octobre 2018

Are there any jquery conflicts in my wordpress code?

I have a wordpress page, where I would like to check a category in the checkbox by using the data-value. In this case "Announcement"

This script works on codepen just fine, but not on wordpress. The following is everything I put on the wordpress page.

jQuery(document).ready(function() {
  var input = $('input[data-value="Announcement"]')
  input.focus();
  input.select();
  input.prop('checked', true);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js">
</script>
<input type="checkbox" id="test" name="category[]" data-wpt-type="checkbox" data-wpt- id="test" data-wpt- name="category[]" value="1" data-parent="-1" data-value="Announcement" class="wpt-form-checkbox form-checkbox checkbox">

<input type="checkbox" id="test2" name="category[]" data-wpt-type="checkbox" data-wpt- id="test2" data-wpt- name="category[]" value="2" data-parent="-1" data-value="Story" class="wpt-form-checkbox form-checkbox checkbox">

Is this a jquery issue/conflict? A theme conflict, or wrong code?




Aucun commentaire:

Enregistrer un commentaire