Understanding how to get and set.
I was trying to make a video page that I could click members in a list and play the video for the title in the list. I realized there may be some things I don' t know about getting and setting attributes or even getting and setting all things in jQuery. Originally I was trying to set the video tags source tags attribute 'src' to the new video and get it to stop the current and play the one the clicked link refers to. I realized I may be missing some know how so I tried to do some thing a lot simpler to see if I understand what is going on. So I put the video functionality aside and tried to create an paragraph tag that just changes color when clicked on. The problem is that I can't change it again once it changes once. What am I doing wrong.
- /* Chris Johnston */
- $(document).ready(function() {
- //alert("Howdy");
- var clickedItem = $('#vidListCon ul li a');
- var vidTo = "";
- $(clickedItem).on('click', function() {
- //alert($(this).attr('num'));
- var vidNow = $(this).attr('num');
- console.log(vidNow);
- vidTo = $('#' + vidNow + ' video source').attr('src');
- console.log(vidTo);
- setVideo();
- });
- function setVideo() {
- //$('#mainVid').attr('src', vidTo);
- if ($('p.r1').attr('class') == 'r1') {
- $('p.r1').attr('class', 'b1');
- } else if ($('p.r1').attr('class') == 'b1') {
- $('p.r1').attr('class', 'r1');
- }
- }
- });
[moderator reformatted]