Hi,
Re this thread: http://www.sitepoint.com/forums/javascript-15/changing-text-click-jquery-554851.html
I am unable to use this following code twice to change text…
$(this).text($(this).text() == 'More Details' ? 'Hide Details' : 'More Details');
Please can some kind soul help me figure this out to change text for multiple ID’s/Div’s.
Here’s my code. Note, I haven’t duplicated the javascript portion again as it breaks the first one that works.
HTML
<a href="#" id="slick-toggle");">More Details</a>
<br />
<div id="myContent" style="background-color: #CCC; padding: 10px;"> <strong>Cover The Fretboard : Theory and Application on Guitar</strong> - <strong>By Ashley Smith
</strong>
<br />
<br />
Contents: -
<br /><br />
<ul>
* <em><strong>About The Author</strong></em>
<br /><br /><br />
* <em><strong>Study Sheet Notes</strong></em> <br />- Important info regarding some documents.
<br /><br /><br />
* <em><strong>Notes On The Fretboard</strong></em> <br />- An easy way to find and identify any note on the neck.
<br /><br /><br />
* <em><strong>Warm Ups</strong></em> <br />- Before you start to play you must Warm Up.
<br /><br /><br />
* <em><strong>How To Tune The Guitar</strong></em> <br />- A guide to tuning your Guitar.
<br /><br /><br />
* <em><strong>Open Position and Moveable Chord Shapes</strong></em> <br />- Basic CAGED and EDCAG Chord Forms.
<br /><br /><br />
* <em><strong>Lead Patterns</strong></em> <br />- Common Lead Patterns.
<br /><br /><br />
* <em><strong>Pentatonic's</strong></em> <br />- Major, Minor and Blues.
<br /><br /><br />
* <em><strong>Arpeggio's</strong></em> <br />- Major, Minor, Diminished, Augmented, Major 7, Minor 7, Dominant 7.
<br /><br /><br />
* <em><strong>The Major Modes</strong></em> <br />- Major Scale Modes and patterns across the entire neck <br />(Ionian, Dorian, Phrygian, Lydian, Mixolydian, Aeolian, Locrian).
<br /><br /><br />
* <em><strong>Diatonic Modal Avoid Notes and Colour Tones</strong></em> <br />- Notes to avoid in scales, and the colour tones.
<br /><br />
</ul>
</div>
<br />
<br />
<br />
<a href="#" id="slick-toggle1");">More Details</a>
<br />
<div id="myContent1" style="background-color: #CCC; padding: 10px;"> <strong>Cover The Fretboard : Theory and Application on Guitar</strong> - <strong>By Ashley Smith
</strong>
<br />
<br />
Contents: -
<br /><br />
<ul>
* <em><strong>About The Author</strong></em>
<br /><br /><br />
* <em><strong>Study Sheet Notes</strong></em> <br />- Important info regarding some documents.
<br /><br /><br />
* <em><strong>Notes On The Fretboard</strong></em> <br />- An easy way to find and identify any note on the neck.
<br /><br /><br />
* <em><strong>Warm Ups</strong></em> <br />- Before you start to play you must Warm Up.
<br /><br /><br />
* <em><strong>How To Tune The Guitar</strong></em> <br />- A guide to tuning your Guitar.
<br /><br /><br />
* <em><strong>Open Position and Moveable Chord Shapes</strong></em> <br />- Basic CAGED and EDCAG Chord Forms.
<br /><br /><br />
* <em><strong>Lead Patterns</strong></em> <br />- Common Lead Patterns.
<br /><br /><br />
* <em><strong>Pentatonic's</strong></em> <br />- Major, Minor and Blues.
<br /><br /><br />
* <em><strong>Arpeggio's</strong></em> <br />- Major, Minor, Diminished, Augmented, Major 7, Minor 7, Dominant 7.
<br /><br /><br />
* <em><strong>The Major Modes</strong></em> <br />- Major Scale Modes and patterns across the entire neck <br />(Ionian, Dorian, Phrygian, Lydian, Mixolydian, Aeolian, Locrian).
<br /><br /><br />
* <em><strong>Diatonic Modal Avoid Notes and Colour Tones</strong></em> <br />- Notes to avoid in scales, and the colour tones.
<br /><br />
</ul>
</div>
Javascript
$(document).ready(function() {
// hides the slickbox as soon as the DOM is ready
$('#myContent').hide();
// toggles the slickbox on clicking the noted link
$('#slick-toggle').click(function() {
$('#myContent').slideToggle('normal');
$(this).text($(this).text() == 'More Details' ? 'Hide Details' : 'More Details');
return false;
});
});
This how it looks…
Thanks very much in advance of a swift reply.
Ash
P.s. I got this code off the Internet and have no experience with Javascript, jQuery, CSS, HTML, etc… I’m a newbie.