Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

I want the ID of the element as the background of the div

I want the ID of the element as the background of the div

Problem

I am trying to add a Background image to each Element on my page. The background images name is same as the id of the page (without the.png)

for example:

/* i want this to have a bg of: background-image:url('1.png')*/
/* i want this to have a bg of: background-image:url('2.png')*/
/* i want this to have a bg of: background-image:url('3.png')*/
Problem courtesy of: Kolos Feri Fazekas

Solution

Try this with jQuery.

Code Modified

var element = $(".ClassOne");
for(var i=0; i
Solution courtesy of: Mayank Tripathi

Discussion

View additional discussion.



This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

I want the ID of the element as the background of the div

×

Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription

×