Set and get help?

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() {

	var clickedItem = $('#vidListCon ul li a');
	var vidTo = "";
	$(clickedItem).on('click', function() {
		var vidNow = $(this).attr('num');
		vidTo = $('#'+vidNow+' video source').attr('src');
	function setVideo() {
		$('#mainVid').attr('src', vidTo);
		if($('p.r1').attr('class') == 'r1') {
		}else if ($('p.r1').attr('class') == 'b1'){


Hi there,

+1 for stepping back from the more complicated problem and trying to understand the underlying principles.

It shouldn’t be too hard to do what you ask, but could you post the HTML that goes with the JS?

Thanks so much to take the time to look at my code, so far I can retrieve the info I want about the video I need to load but can’t seem go get the video to change. I would really like to know what concepts I am weak on in jQuery so I can try to brush-up and get better at making pages do what I want. I have replaced the video with some test content because my original video and content and video was very large. Thanks

Hi there,

I downloaded the zip file, but am not really sure how this relates to changing the colour of a paragraph tag when you click on it, which was what I understood your original question to be.

Oh thank you, I thought the request for code was to look at why I went to the part with the change I did that so I could try to see what was not changing. Why is because that I was not sure that other factors of the page and video and it properties were not have result I did not account for. When I posted the code that is where I currently was. This is what I am ultmately trying to understand, if we don’t even deal with the video changing I am working on changing the html of the description when I click. I have been doing some more reading studying and I think I am near the concepts that I originally used the the first example to describe. This or these are the concepts that will make doing what I want possible. However if I need to restate what my overall problem was that made look to simpler concepts; it is that I cant get the video to change when I click the links, also I want the description to change as well. If it is a lot to digest don’t worry I was not looking for someone to solve rather that point me in the correct direction(but feel free to solve a well). I say point in the correct direction because that is when I learn. Thanks


I would rather help you solve the problem of creating a paragraph tag that just changes color when clicked on, then applying what we learn there to the bigger problem of getting your videos to display as you want.

So let’s start over.

Can you post what the code you have regarding the paragraphs and tell us where you are getting stuck.

Hi thank you for all the help I have been swamped with work is the reason for the delay. I do find the time to squeeze in some reading and study at the jQuery website. I say this to say to date I think I understand the problem (original we should step back to). I think by some chaining I can addClass and removeClass via the click function. I plan to test this soon, but your help to understand is greatly appreciated. Once again that was the changing of the color via the click function of the description <p> tag. Thanks so much
Original Stepped back problem code:

Hi there,

Again, you’ve forced me to download 15MB and you still haven’t explained your problem.

What I would like to see is this:

I really don’t want to have to download 15MB of videos, read back through your old posts to work out what it is you wanted, then hunt around all of the files you included in the zip file, just so that I can find where I think the problem might possibly be.

If you make it hard for people to help you, then your chances of getting an answer will go down.

Yes, I see what you mean. I did not think the download was that cumbersome. I will construct the code minus the video part. Thanks