+ 1

How to create onclick event in unorganised list,...

<ul><li><a herf="#">MY PAGE</a></ul>, I want to add ON CLICK EVENT BASED ON INNER HTML, USING JAVASCRIPT

7th Jul 2017, 1:33 PM
ASHISH PANDEY
ASHISH PANDEY - avatar
10 Réponses
+ 5
What is herf? Was it supposed to be href or smthing else?
8th Jul 2017, 2:40 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
easiest is <li onclick="yourFunction()"> add the attribute `onclick`
7th Jul 2017, 1:35 PM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 4
show ur code
7th Jul 2017, 1:37 PM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 4
if u have a text? wrap it with span tag <span onclick="()">my text</span> like this?
7th Jul 2017, 1:43 PM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 2
I think you didn't make closing tag for <li> 😕😕
7th Jul 2017, 3:42 PM
Mohammed Qabbari
Mohammed Qabbari - avatar
+ 1
not working,
7th Jul 2017, 1:36 PM
ASHISH PANDEY
ASHISH PANDEY - avatar
+ 1
I did that, let me try again
7th Jul 2017, 1:37 PM
ASHISH PANDEY
ASHISH PANDEY - avatar
+ 1
thanx, it happens, but what if I have condition....like based on text "my page"....
7th Jul 2017, 1:39 PM
ASHISH PANDEY
ASHISH PANDEY - avatar
+ 1
logic wrong, in if condition....
7th Jul 2017, 1:39 PM
ASHISH PANDEY
ASHISH PANDEY - avatar
+ 1
OK, thanx...
7th Jul 2017, 1:45 PM
ASHISH PANDEY
ASHISH PANDEY - avatar