Simulating a click depending on a url parameter in javascript
-
15-11-2019 - |
Question
I have a parameter which is appended to the url. Depending on the value of this parameter, I need to simulate a click on a dropdownbox item. I tried to use the selected index and it works. However, when using the selected index, it doesn't function like a click and I have some functionality which is only shown when there is a click on the dropdown item.
The URL is something like this:
http://www.mydomain.com/mypage.html?paramName=paramValue
Is there a way in javascript how I can achieve this? I tried the .click() event but to no avail.
Many thanks
Solution
Move the code out of the .click
event handler, and call this new function from both locations (click handler & on URL parsing).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow