+ 5
Please help me I want to my search when finde that image value make img border 1 px sold how write right?
11 ответов
+ 3
Like what @Paola said, we cannot use same id for multiple times, use class instead.
Just modified @Mr Programmer code: :p
<img src="watch.png" class="watch">
<img src="watch1.png class="watch">
now under the onclick method of the button
write
var watches = document.getElementsByClassName("watch");
for (var i=0;i <watches.length;i++)
watches[i].style="border: 2px solid #000";
+ 10
Let me see if I understood, after seeing your code:
When you search on the input bar and hit the "Creat" button, you want to able to find the images with src value "watch" and set a border 1px solid to them?
You shouldn't try to do it with the src values but rather give all the images a class that indicates which ones are about watches and which ones are not.
Let me know if this is the outcome you are seeking and I might be able to code it.
+ 9
@MR Programmer yeah, I understood that too, but an Id must be unique, it may not be used more than once in the same document so we can differentiate each element from another, that's why I suggested using a class. But great Javascript approach 👍
+ 4
what i understood
add id ex
<img src="watch.png" id="watch">
<img src="watch1.png id="watch">
now under the onclick method of the button
write
document.getElementById("watch").style="border-width: 2px 2px 2px 2px;";
+ 3
I want to make border in all images which have a watch name
+ 2
You want an image with border width 1px?
+ 2
Hopefully this is the sample you were searching for.. :)
https://code.sololearn.com/WjAUKB7RH6m7/?ref=app
+ 2
thx can u say me how I can my thats image adding in other div when I will click on thim.... I want when I will click my second div will show and that of div I will see my image and after when I will click and second image that's also add in div
+ 1
you want the selected images to have border with it?
+ 1
@paola yep you can use class or a name