Reputation: 919
I am having trouble with selecting the text within a span tag (this is in a template, I cannot edit the text directly), here is the HTML:
<table class="worf">
<tbody>
<tr>
<td colspan="2" class="brown45">
<span id="red24">Quantity and Pricing</span>
Here is what I tried:
<script>
$('#red24').text('Confirm Your Reservation');
</script>
Upvotes: 1
Views: 94
Reputation: 1820
Allways when the document is ready.
I think it'd be the best to use .html() you can use it just for a add text :
$('#red24').html('whathever');
or it'd be the best if you prefer to make it visible or with another style or class for instance :
$('#red24').html('<p class="foo"><b>Confirm Your Reservation</b></p>');
Upvotes: 0
Reputation: 128781
You need to wrap jQuery code in a $(document).ready()
function:
<script>
$(document).ready(function() {
$('#red24').text('Confirm Your Reservation');
});
</script>
Upvotes: 4