Reputation: 3857
I have this span
<a title="Prev" data-event="click"
data-handler="prev" class="ui-datepicker-prev ui-corner-all">
<span class="ui-icon ui-icon-circle-triangle-w">Prev</span>
</a>
I need to set the text of the span to be <<
instead of its current text Prev
.
I tried this below, but it didn't change the text as I'd expected. How can this be done?
$(".ui-icon .ui-icon-circle-triangle-w").html('<<');
Upvotes: 75
Views: 257203
Reputation: 2283
Try it.. It will first look for anchor tag that contain span with class "ui-icon-circle-triangle-w", then it set the text of span to "<<".
$('a span.ui-icon-circle-triangle-w').text('<<');
Upvotes: 3
Reputation: 1171
Give an ID to your span and then change the text of target span.
$("#StatusTitle").text("Info");
$("#StatusTitleIcon").removeClass("fa-exclamation").addClass("fa-info-circle");
<i id="StatusTitleIcon" class="fa fa-exclamation fa-fw"></i>
<span id="StatusTitle">Error</span>
Here "Error" text will become "Info" and their fontawesome icons will be changed as well.
Upvotes: 2
Reputation: 339786
You need to fix your selector. Although CSS syntax requires multiple classes to be space separated, selector syntax would require them to be directly concatenated, and dot prefixed:
$(".ui-icon.ui-icon-circle-triangle-w").text(...);
or better:
$(".ui-datepicker-prev > span").text(...);
Upvotes: 5
Reputation: 103348
Use .text()
instead, and change your selector:
$(".ui-datepicker-prev .ui-icon.ui-icon-circle-triangle-w").text('<<');
Upvotes: 144
Reputation: 145368
This is because you have wrong selector. According to your markup, .ui-icon
and .ui-icon-circle-triangle-w"
should point to the same <span>
element. So you should use:
$(".ui-icon.ui-icon-circle-triangle-w").html("<<");
or
$(".ui-datepicker-prev .ui-icon").html("<<");
or
$(".ui-datepicker-prev span").html("<<");
Upvotes: 13