I've a CSS id which shows a small red ball and a JAVASCRIPT function. I want to pass the CSS id as a parameter in the JavaScript function. I've seen a lot of tutorials but can't figure it out. Here are the codes:
CSS code
#projectile{
position: absolute;
background-color: #ff0000;
left:176px;
top: 486px;
width:10px;
height:10px;
border-radius: 8px;
z-index: 9;
}
JAVASCRIPT code
function gofish(projectile_id){
var projectile = getElementbyId(projectile_id);
start_x = projectile.offset().left;
start_y = projectile.offset().top;
function init()
{ setTimeout("gofish('projectile')", 500); }
getElementbyIdfunction, or did you actually meandocument.getElementbyIdoffset()function ?getElementbyIdanddocument.getElementbyIdbut nothing worked. And yes I'm using jquery offset function.