I have the following HTML
<input type="text" name="first" expression="firstExpression"/>
<input type="text" name="last" expression="secondExpression"/>
<input type="text" name="age" expression="thirdExpression"/>
I have a custom expression attribute.
I using jQuery to iterate over all the input elements, and although I will need to do something later, I need to be able to grab the expression value for each of these input elements, and compare it to the value of that input element.
I am able to grab the expression value by doing the following
var expressionValue = inputs.attr("expression");
but that only grabs the expression value of the following, I need to be able to do the same thing such as the following scenario
function showValues()
{
var inputs = $(":input[expression]");
inputs.each(function(index){
var input = inputs[index];
//need to be able to get 'expression' from input var here
});
}
the code above is correctly grabbing all the elements I need, but I am unable to figure out how to grab the value of the expression attribute
use the $.each
like this:
function showValues()
{
var inputs = $("input[expression]");
console.log(inputs); //output input for debug
inputs.each(function(){
console.log(this,$(this).attr('expression'));//show expression (for debug)
});
}
showValues();
fiddle: http://jsfiddle.net/maniator/LmW8P/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With