+ 5

Please help me I want to my search when finde that image value make img border 1 px sold how write right?

https://jsfiddle.net/sov3ovmg/

5th May 2017, 11:45 AM
Kristina Hakobyan
Kristina Hakobyan - avatar
11 Réponses
+ 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";
6th May 2017, 2:37 AM
Calviղ
Calviղ - avatar
+ 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.
5th May 2017, 9:22 PM
Pao
Pao - avatar
+ 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 👍
5th May 2017, 10:53 PM
Pao
Pao - avatar
+ 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;";
5th May 2017, 9:43 PM
MR Programmer
MR Programmer - avatar
+ 3
I want to make border in all images which have a watch name
5th May 2017, 12:12 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
+ 2
You want an image with border width 1px?
5th May 2017, 12:11 PM
Calviղ
Calviղ - avatar
+ 2
Hopefully this is the sample you were searching for.. :) https://code.sololearn.com/WjAUKB7RH6m7/?ref=app
5th May 2017, 12:40 PM
Calviղ
Calviղ - avatar
+ 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
6th May 2017, 5:28 AM
Kristina Hakobyan
Kristina Hakobyan - avatar
+ 1
you want the selected images to have border with it?
5th May 2017, 12:16 PM
Calviղ
Calviղ - avatar
+ 1
@paola yep you can use class or a name
5th May 2017, 11:04 PM
MR Programmer
MR Programmer - avatar