3

What is .src in the JavaScript code below?

function jsDropDown(imgid,folder,newimg) {
    document.getElementById(imgid).src="http://www.cookwithbetty.com/" + folder + "/" + newimg + ".gif";
}

4 Answers 4

8

It's the src DOM property of the <img> element that it's dealing with.

Sign up to request clarification or add additional context in comments.

7 Comments

so, what the function and why can it use in javascript?
@dramasea - I don't follow the question, can you clarify a bit?
you are simply setting an element's property like you would with any property, in this case src is the source of an image. But as everyone said, it is simply a specific dom property that you can access. "src" is not a function but a property name of the object "img"
so the above function is to grab the following image with id imgid and change the source to source that specify?Thanks
@dramasea - yup, that's exactly what it's doing :)
|
1

It maps onto the src attribute of the img element. (Although this is DOM rather than JS)

Comments

0

src is the property of <img> tag and can be accessed by javascript to assing the image url

Comments

-2

src is in computer programming, a common abbreviation for source code.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.