Michael:
Yes, Indeed! That works perfectly! Thank you!
And it seems so simple and obvious in retrospect. g
Actually, I hadn't realized that I could put the selector into a
variable and reuse it that way, so you've taught me something else
new.
Harvey
Glad I could be of assistance, Harvey.
Yes, you can put anything into a variable! :-)
It's especially useful to save a jQuery object in a variable as in this
code:
var $input = $([id$=+b1+] input);
$input.val( $input.val() == Hide ? Show : Hide );
This way the fairly expensive search that
hsfrey ha scritto:
function togl(b1) {
var t1 = document.getElementById(b1).getElementsByTagName(input);
var labl = t1[0].value;
t1[0].value = labl==Hide?Show:Hide;
...
}
In addition, rather than just Match the ID, I want to match the ID
which ENDS in the string
Giovanni:
Thanks for the suggestion, but, unfortunately it doesn't do
anything . :-(
However, I tried the following:
$([id$=+b1+] input).val(Hide?Show:Hide);
This actually does switch the label to show, but not back to
hide when clicked again.
BUT - I'm as confused about why it DOES
Let's break that statement down into individual statements:
var selector = [id$= + b1 + ] input;
var value = ( Hide ? Show : Hide );
$(selector).val( value );
Now what is in the variable 'value'? You can try alerting it:
var value = ( Hide ? Show : Hide );
alert( value ); // always alerts
Giovanni:
Thank you for your response.
I can't understand what value are you looking for, but should be something
link $('#id').val() or $(this).val().
I'm trying to get the jQuery code to replace this JS which works to
toggle the label:
function togl(b1) {
var t1 =
Your welcome!
Envoyé de mon iPod
Le 2009-10-08 à 22:57, hsfrey hsf...@gmail.com a écrit :
Giovanni:
Thank you for your response.
I can't understand what value are you looking for, but should be
something link $('#id').val() or $(this).val().
I'm trying to get the jQuery code to
hsfrey ha scritto:
In this line of code, I'm looking for a div whose Id is in variable
b1, and which has an input button field whose value is Show or
Hide, and this line is to toggle those values.
$(([id$=+b1+]) input).attr(value, attr(value)
==Hide?Show:Hide);
This doesn't work, and Firebug
8 matches
Mail list logo