I have a function that detects all input value changes with keyup:
Jquery:
// detect all inputs
$('.inputChange').each(function() {
// Save current value of element
$(this).data('oldVal', $(this).val())
// Look for changes in the value
$(this).bind("propertychange keyup input paste", function(event){
// If value has changed...
if ($(this).data('oldVal') != $(this).val()) {
// Updated stored value
$(this).data('oldVal', $(this).val())
currentVal = $(this).val()
// Do action
inputElement = $(this).attr('data-element')
inputProperty = $(this).attr('data-property')
inputUnit = $(this).attr('data-unit')
updateAllCSS(inputElement, inputProperty, currentVal + inputUnit)
}
});
});
HTML:
<input class="inputChange" data-element=".homeTemplate #colaAlpha h1" data-property="font-size" data-unit="px">px
I now need to do another that will get the selected dropdown values from this HTML:
<select class="selectChange" data-element=".homeTemplate #colaAlpha" data-property="height" data-unit="px">
<option value="8">8px</option>
<option value="12">12px</option>
<option value="21">21px</option>
</select>px
I was wondering how I should go about doing this? is there perhaps a propertychange event that will work?
Have a look at http://api.jquery.com/change/: