I have a CSS id that shows a small red ball and a JAVASCRIPT function. I want to pass the CSS id as a parameter in a JavaScript function. I saw a lot of textbooks, but I can’t understand. 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); }
source
share