Nura111
asked on
jquery toggle two elements
Im trying to toggle 2 elements :
when I just toggle one its worked any idea?
function toggleLeadBody(id) {
var fieldname1 = "spam_"+ id + "_body";
var fieldName2 = "sr_" + id + "_body";
var element = $('#' + fieldName1, '#' +fieldName2);
element.toggle();
}
when I just toggle one its worked any idea?
function toggleLeadBody(id) {
var fieldname1 = "spam_"+ id + "_body";
var fieldName2 = "sr_" + id + "_body";
var element = $('#' + fieldName1, '#' +fieldName2);
element.toggle();
}
<tr style="border-style: solid; border-width: 1px;">
<td colspan="5"
style="color: blue; display: none; padding: 0px 25px 0px 25px;"
id="sr_{$row['id']}_body"
>
Subject: {$row['subject']}<br />
{$message}
<td colspan="5"
style="color: red; padding: 0px 25px 0px 25px;"
id="spam_{$row['id']}_body"
>
Mark as spam
</tr>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
may help : http://jsfiddle.net/9UFge/
<span>Select a State</span>
<select>
<option value="">Select a State</option>
<option value="AL">Alabama</option>
<option value="CA">California</option>
</select>
$("span").click(function() {
$("select").css("display","block");
})
$("select").change(function() {
$("span").html( $("option:selected",this).text() );
$("select").css("display","none");
})
ASKER
no its not working :
function toggleLeadBody(id) {
var fieldname1 = "#spam_"+ id + "_body";
var fieldName2 = "#sr_" + id + "_body";
var element = $(fieldName1 + ',' + fieldName2);
element.toggle();
//element = $('#'+ fieldName2);
//element.toggle();
}
function toggleLeadBody(id) {
var fieldname1 = "#spam_"+ id + "_body";
var fieldName2 = "#sr_" + id + "_body";
var element = $(fieldName1 + ',' + fieldName2);
element.toggle();
//element = $('#'+ fieldName2);
//element.toggle();
}
i guess it has to be done separately only, one by one
ASKER
yes I tried that also its not working as well:
function toggleLeadBody(id) {
var fieldname1 = "#spam_"+ id + "_body";
var fieldName2 = "#sr_" + id + "_body";
var element2 = $(fieldName2);
element2.toggle();
var element1 = $(fieldName1);
element1.toggle();
//element = $('#'+ fieldName2);
//element.toggle();
}
maybe the problrm is in the html?? I cant see any problem but I attached it before to the question as a code
function toggleLeadBody(id) {
var fieldname1 = "#spam_"+ id + "_body";
var fieldName2 = "#sr_" + id + "_body";
var element2 = $(fieldName2);
element2.toggle();
var element1 = $(fieldName1);
element1.toggle();
//element = $('#'+ fieldName2);
//element.toggle();
}
maybe the problrm is in the html?? I cant see any problem but I attached it before to the question as a code
when you say, it doesn't work what do you mean?
also, how are these two elements related to each other?
also, how are these two elements related to each other?
ASKER
its mean that its not showing the elements when clicking on the event the starting toggleLeadBody() function.
ASKER
the two element need to show together when clicking
ASKER
sorry to trouble you in a stupid mistake the var fieldname1 was with small letter. that was it..
ID:36568886 (bad thread, sorry)
ASKER
The main one worked as well but this is other suggestion..
ASKER
when I used function toggleLeadBody(id) {
var fieldName = "sr_" + id + "_body";
var element = $('#' + fieldName);
element.toggle();
}
for one elemet before it was ok