I'm trying to run a javascript/jquery code inside a PHP function in wordpress. Actually I found this code at this link: http://jsfiddle.net/fXrv2/
As you can see, it works perfectly. But it seems that something is missing in my final code bellow, because the text-field isn't able to auto complete the number format.
Any idea why is it not working?
<?php
function teste() {
?>
<script type="text/javascript">
$('input.number').keyup(function(event) {
// skip for arrow keys
if(event.which >= 37 && event.which <= 40){
event.preventDefault();
}
$(this).val(function(index, value) {
return value
.replace(/\D/g, "")
.replace(/([0-9])([0-9]{2})$/, '$1.$2')
.replace(/\B(?=(\d{3})+(?!\d)\.?)/g, ",")
;
});
});
</script>
<input type="text" class="number">
<?php
}
seems that something is missingQuestions should have a clear problem statement, or no one will know what your issue is.