Simple Machine Codes
March 28, 2024, 09:34:18 am
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome to SMC, the best place for your SMF For Free Codes
 
  Home Help Search Arcade Gallery Affiliates Code Index Staff List Calendar Members Login Register  

Jquery and SMF For Free #4(Selecters Part 1)

Pages: [1]   Go Down
  Print  
Author Topic: Jquery and SMF For Free #4(Selecters Part 1)  (Read 546 times)
0 Members and 1 Guest are viewing this topic.
Agent Moose
Administrator

Offline Offline

Gender: Male
Posts: 2,672



View Profile WWW
« on: February 26, 2008, 08:10:36 pm »

Here I will show you the diffrent ways to Select which element you want Smiley

This is basicly just an Add-on to the First Jquery and SMF For Free Tutorial.

So, now to start.

[attribute] - Matches elements that have the specified attribute.
[attribute=value] - Matches elements that have the specified attribute with a certain value.
[attribute!=value] - Matches elements that don't have the specified attribute with a certain value.
[attribute^=value] - Matches elements that have the specified attribute and it starts with a certain value.
[attribute$=value] - Matches elements that have the specified attribute and it ends with a certain value.
[attribute*=value] - Matches elements that have the specified attribute and it contains a certain value.
[selector1][selector2][selectorN] - Matches elements that have the specified attribute and it contains a certain value.

In this tutorial, I will be using this as the example:
Code:
<table id='Table_1'>
  <tr>
     <td width='100%'>TD 1</td>
     <td width='20%'>TD 2</td>
     <td name='TD3' width='100%'>TD 3</td>
     <td name='TheLongNameThatIsLong'>TD 4</td>
  </tr>
</table>

[attribute] - Matches elements that have the specified attribute.
Code:
<script>
$("table[width]").append("<b>Hey</b>");
</script>
That would append Text to the First, Seond, and Third TD.


[attribute=value] - Matches elements that don't have the specified attribute with a certain value.
Code:
<script>
$("table[width='100%']").append("<b>Hey</b>");
</script>
That would append Text to the First and Third TD.

[attribute!=value] - Matches elements that don't have the specified attribute with a certain value.
Code:
<script>
$("table[width!='100%']").append("<b>Hey</b>");
</script>
Would append Text to the Second, and Fourth TD.


[attribute^=value] - Matches elements that have the specified attribute and it starts with a certain value.
Code:
<script>
$("table[width^='Long']").append("<b>Hey</b>");
</script>
Would append Text to the Fourth TD.


[attribute$=value] - Matches elements that have the specified attribute and it ends with a certain value.
Code:
<script>
$("table[width$='Long']").append("<b>Hey</b>");
</script>
Would append Text to the Second, and Fourth TD.


[attribute*=value] - Matches elements that have the specified attribute and it contains a certain value.
Code:
<script>
$("table[width*='0']").append("<b>Hey</b>");
</script>
Would append Text to the First, Second, and Third TD.


[selector1][selector2][selectorN] - Matches elements that have the specified attribute and it contains a certain value.
Code:
<script>
$("table[width='100%'][name='TD3']").append("<b>Hey</b>");
</script>
That would only append text to the Third TD.
You can add as much attributes you want Smiley


Well, This tutorial is very basic.  If you have any problems, just ask Smiley
« Last Edit: March 16, 2008, 09:50:20 pm by Agent Moose » Report Spam   Logged

Share on Facebook Share on Twitter



Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy