In this tutorial, you will learn how to change certain text. I will be using my "Change 'Child Board' Text" as an example to help you out.
ok, first you will need to start the script with the script tags:
<script>
</script>
Now you will need to add the funtion to make the code work smoothly,
NOTE: you don't have to have this part, just makes the code load smoothly and faster.
<script>
function childboard_text(){
//Created by Agent Moose
$(function() {
});}
childboard_text();
</script>
Now that you have that done, you can start by getting the elements you need to change the text. First you will need to find the text.
<script>
function childboard_text(){
//Created by Agent Moose
$(function() {
$("span b")
});}
childboard_text();
</script>
What I useually do is have the least ammount of tags so that the code will be smaller. You can see that all I needed to get was a span tag and a bold tag since the text your trying to get is inside those tags.
Now you want to accually grab the text that you want to change.
<script>
function childboard_text(){
//Created by Agent Moose
$(function() {
$("span b").contains("Child Boards")
});}
childboard_text();
</script>
So now you see that since I added the contains("Child Boards") it is getting that text.
Now that you have the text, you will want to accually change the text.
<script>
function childboard_text(){
//Created by Agent Moose
$(function() {
child = "CHILDBOARD TEXT"
$("span b").contains("Child Boards").html(child);
});}
childboard_text();
</script>
I have added the .html(child) part because that is waht the new html will be, in this case, the text. You see the word "child" in between the perenthases of HTML because that is a variable, and that is where the child = "CHILDBOARD TEXT" comes in. The dhild = is the accual variable that holds the content of the words taht you want to change "Child Boards" to. That content goes to the .html(child) which makes the text change.
So basicly, if you wanted you could use this code, which is shorter, but the way I did it, makes it easyer to understand.
<script>
function childboard_text(){
//Created by Agent Moose
$(function() {
$("span b").contains("Child Boards").html("CHILDBOARD TEXT");
});}
childboard_text();
</script>
And that is all for the tutorial of how to change text. I hope you found it usefull.
I will make a tutorial on variables later...
More tutorial soon at smcodes.smfforfree3.com