Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  4] [ 4]  / answers: 1 / hits: 17864  / 14 Years ago, wed, december 8, 2010, 12:00:00

I've got a collapsible link which has the unicode arrow on it



►This is a collapsible link


And when someone clicks on it I want it to be turned into the down arrow ▼. However I am having trouble figuring out how to parse to replace this character.



Here is my code:



function CollapsibleContainerTitleClickApp(){
$(.collapsibleContainerContent.app, $(this).parent()).slideToggle();
alert($(this).text().trim().charAt(0));
if ($(this).text.trim().charAt(0) == u25B8{
alert(inside the if statement);
$(this).text($(this).text().replace(u25B8, u25BE));
}else{
$(this).text($(this).text().replace(u25BE, u25B8));
}


Now the first alert always pops up as the actual arrow (►) and viewing the source also has the actual arrow. How can I see if the first character is one arrow, and if so replace it with the other arrow? The second alert statement never fires so it's never passing the condition of the if.


More From » jquery

 Answers
9

You have multiple errors in your if statement, this is why that branch is never hit.



if ($(this).text.trim().charAt(0) == u25B8{


You forgot the closing ) of the if statement.



Also, you're not invoking the text() method, you're trying to access it as a member, which it isn't.



Your code should look like this:



if ($(this).text().trim().charAt(0) == u25B8) {

[#94684] Monday, December 6, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hanna

Total Points: 66
Total Questions: 99
Total Answers: 101

Location: Saudi Arabia
Member since Sat, Aug 20, 2022
2 Years ago
;