Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
c# ASPNET rightclick event
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Permudious" data-source="post: 481869" data-attributes="member: 55273"><p>Seems like this is working for me <img src="/styles/default/xenforo/smilies/emojione/smile.png" class="smilie" loading="lazy" alt=":)" title="Smile :)" data-shortname=":)" /></p><p>[automerge]1716878399[/automerge]</p><p>How about a simple click event in this case?</p><p></p><p>I have a foreach with for now 8 div's, each div have to increment users and decrement.</p><p>I used the case above and change a bit. it should work I guess. Only I will get a error</p><p></p><p>[CODE]TypeError: this.getAttribute is not a function</p><p> at Playground:142:31</p><p> at NodeList.forEach (<anonymous>)</p><p> at HTMLDocument.<anonymous> (Playground:141:32)[/CODE]</p><p></p><p>[CODE=html]<div class="ManualControl"></p><p> <button class="IncrementUser" id="xIncrementUser" data-id="@ObjectID">+</button></p><p> <button class="DecrementUser" id="xDecrementUser" data-id="@ObjectID">-</button></p><p></div>[/CODE]</p><p>[CODE=javascript] document.addEventListener('click', function () {</p><p> var buttonWithNameElements = document.querySelectorAll('.IncrementUser');</p><p> buttonWithNameElements.forEach(function (element) {</p><p> var object = this.getAttribute('data-id');</p><p> console.log(object);</p><p> });</p><p> });[/CODE]</p></blockquote><p></p>
[QUOTE="Permudious, post: 481869, member: 55273"] Seems like this is working for me :-) [automerge]1716878399[/automerge] How about a simple click event in this case? I have a foreach with for now 8 div's, each div have to increment users and decrement. I used the case above and change a bit. it should work I guess. Only I will get a error [CODE]TypeError: this.getAttribute is not a function at Playground:142:31 at NodeList.forEach (<anonymous>) at HTMLDocument.<anonymous> (Playground:141:32)[/CODE] [CODE=html]<div class="ManualControl"> <button class="IncrementUser" id="xIncrementUser" data-id="@ObjectID">+</button> <button class="DecrementUser" id="xDecrementUser" data-id="@ObjectID">-</button> </div>[/CODE] [CODE=javascript] document.addEventListener('click', function () { var buttonWithNameElements = document.querySelectorAll('.IncrementUser'); buttonWithNameElements.forEach(function (element) { var object = this.getAttribute('data-id'); console.log(object); }); });[/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
c# ASPNET rightclick event
Top