You’ll see that the blue blocks can be hovered over, and the content to the left changes along with the images, somewhat like a custom slider. How I achieved that was simple and can be seen here: http://cpointweb.com/dtv/js/custom.js
I want to expand this so that the content fades in and the images slide in upon each hover. Since being so new to all this javascript stuff I am somewhat at a cross-roads (mentally more than anything, hehe).
Can anyone point me in the right direction as to how I could achieve something like what I mentioned above? Is my current way of doing this incapable of what I described above? Seems like it to me, as I am just replacing text and such.
I don’t want the code written for me, I like to learn but am just not sure where to begin with something like that.
But, for this to work properly and look good, you’re going to have to build a function to handle this and make your program DRY. So this way, you can just pass in info instead of copy and pasting it and changing a couple things like you have done.
Something like:
function changeSlider(header, html, img) {
var rightHtml = '<h2>' + header + '</h2><p>' + html + '</p>';
var slider = '<img src="' + img + '" />';
// set the data to the elements and do your fadein/fadeout/fadetoggle stuff here
}
Is there any way you can expand just a little on the code your provided? I’m having trouble understanding how I set the data to the elements and how I then implement this on the front-end with my current HTML.
As I understand it, I call the function with a simple changeSlider(“My H2 Tag”, “Any Text Here”, “…/img-source.jpg”);
But through the front-end, since they are two separate areas, how would I then accomplish this? Or is it a matter of re-arranging code? Maybe I am thinking about this far more difficult than I should be.
I am going through some books I have as well, just figured I’d ask as well.
I love it! I’ve been designing/building sites for years and have never gotten into Javascript, but I love what I can do so far! Don’t know why I never picked this up before.
Thanks so much for all the help, I really appreciate it! Learned a lot so far this morning.
Not necessarily programming. I have good experience with PHP/MySQL but have never gotten into JS for whatever reason. 8 years in and I’m scratching my head as to why, hehe.