How to get css selector of clicked-on element?

How to get css selector of clicked-on element?

By : user3100754
Date : January 12 2021, 09:11 PM
I think the issue was by ths following , 1st of all, placing your code into a DOM load event like @eytienne already mentioned is used to make sure the page is loaded before attaching your event. 2nd: you should not need to attach several handler, just one click handler on document- then use the target to get the actual element that was clicked, e.g.
code :
const handler = function(e) {
  const elem = e.target;
document.addEventListener('click', handler, false);
const target = e.target;
for (let i=0,elems=document.querySelectorAll(..);i<elems.length;i++) {
if(elems[i] === target) {
 ... do something ...

Share : facebook icon twitter icon
Applying jQuery selector to table when element is clicked

Applying jQuery selector to table when element is clicked

By : WandaLeT
Date : March 29 2020, 07:55 AM
Any of those help I think I am having a problem with the scope of 'this' when needing to do a simple css change on an element based on an Ajax return. , You should set the context option in the AJAX request to this;
code :
    context: this,
var that = this;

        // Use `that` instead of `this` in here.
});//end ajax
jquery this selector after clicked element removed

jquery this selector after clicked element removed

By : LyoB
Date : March 29 2020, 07:55 AM
like below fixes the issue I want to empty content of div with class dialogBody and then append returned ajax response. See the code below please. The problem I have is .html(response) doesn't do anything because clicked element is removed. How can I carry over the target element which is $this.closest('.dialogBody') after clicked element was removed? , Assign it to a variable:
code :
$(".ajaxReplace").live("click", function(e){
  var $this = $(this);
  var $dBody = $this.closest('.dialogBody').empty();   // <------       
  ajaxUrl = $(this).attr("href")+"?ajax=1";
    type: "POST",
    url: ajaxUrl,
    success: function(response){          
      $dBody.html(response);  // <------
JQuery Selector for hasClass or Previously Clicked Element

JQuery Selector for hasClass or Previously Clicked Element

By : Nathan Cook
Date : March 29 2020, 07:55 AM
I hope this helps . Basically I am combining a filter/sort script with a gallery/thumbnail script. Everything works well apart from changing the opacity of the elements when clicking on the new image. ie. Click on new thumbnail, fades to 1.0, old one fades to 0.3. , This part of your code is where your problem lies:
code :
if($("#thumbs ul.thumbs li").hasClass("counter")) {
    $("#thumbs ul.thumbs li").fadeTo('fast', 0.3);
// Select any li element with the counter class
var $counter = $("#thumbs ul.thumbs li.counter");

// Check whether any $counter elements exist
if ($counter.length > 0) {
    // If they does exist, make them fade out
    $counter.fadeTo('fast', 0.3);

    // Finally, remove the counter class from them

// Add the counter class to the li element which was clicked on
Jquery selector not working after an element is clicked

Jquery selector not working after an element is clicked

By : Zacharias Poikilidis
Date : March 29 2020, 07:55 AM
seems to work fine In your fill function you recreate .sel elements so they dont have click events any more. They considered to be new. You have to bind event every time you insert new html in container
code :
var x = $(".container").width();
var l = 50 - (((25 / x) * 100) - ((10 / x) * 100));
  "left": l + "%"

$(".foot").click(function() {

var rand, i, z, htm;

$(document).ready(function() {

function fill() {
  rand = 0;
  htm = "";
  for (i = 0; i < 5; i++) {
    while (rand < 100000) {
      rand = Math.floor(Math.random() * 1000000);
    htm +=
      "<" + "div class='sel' bg='" + rand + "'" + ">" +
      "<" + "div class='content-left' bg='" + rand + "'" + ">" +
      "<" + "div class='colordot' style='background-color: #" + rand + "'" + ">" + "<" + "b" + ">" +
      (i + 1) +
      "<" + "/" + "b" + ">" +
      "<" + "/div" + ">" +
      "<" + "/div" + ">" +
      "<" + "div class='content-right'" + ">" +
      "#" + rand +
      "<" + "/div" + ">" +
      "<" + "/div" + ">";
    rand = 0;
    z = "";


function bindEvents() {
  $(".sel").on('click', function() {
    z = $(this).attr("bg");
      "background-color": "#" + z
In Angular 2 is it possible to invoke a selector element when some other element is clicked?

In Angular 2 is it possible to invoke a selector element when some other element is clicked?

By : Mark Dietsch
Date : March 29 2020, 07:55 AM
Hope that helps I doesn't find anything in api docs but after I checked the source of calendar I found out that there is an @input property that it's job is to show or hide the calendar.
@Input() showCalendar: boolean;
Related Posts Related Posts :
  • redux how to use state
  • All data in the db is lost when closing a express based node js server
  • How to convert javascript code for Angular
  • XPath select on child nodes
  • Idle event on mouse move - how to stop script permanently on mouse move
  • Why do I get logic is not defined in this code
  • When I enter a number in the input, the first function starts
  • ES6 imports and node_modules hell
  • How to auto input MySQL data (input column 1 data to auto input column 2 data with same column) in php?
  • Appending to Datalist Via Javascript
  • Customizing Material-UI Components with Styled-Components
  • Populate elements with class name using Javascript
  • How to execute promises in batches (first resolving 10, then next 10 and so on)
  • Maximo JS automation script: "importPackage" is not defined
  • How to surround selected text inside textarea with <em> on key combination CTRL+i?
  • Your configured registry does not support audit requests ~ On npm audit
  • What's the Angular equivalent of Vue <slot/>?
  • Iconify icon not updating when "data-icon" set with setAttribute()
  • Javascript newbie stuck with XMLHttpRequest return data
  • How to add obj to to state in my example Redux React
  • Loading "grunt-karma.js" tasks...ERROR >> SyntaxError: Unexpected identifier
  • Why do I get log is not defined
  • get the multiple index of the same string
  • How can I iterate over an Array object by using For IN or FOR OF
  • Launch local executable from web browser
  • How to prepare array of json objects to d3 hierarchical tree structure
  • VueJS - event emitted - show HTML before other calculations
  • Export SASS/SCSS variables to Javascript without exporting them to CSS
  • How to attach an event handler only once continuously
  • How to make button open a link in new tab in JavaScript?
  • Find range from the javascript object
  • How can I use my jQuery code as JavaScript?
  • How to show 5 images in a 2 row slider with bxslider
  • How to convert stream into variables in typescript
  • Three.js custom shader error on Chrome GL_INVALID_OPERATION: Active draw buffers with missing fragment shader outputs
  • My JavaScript doesn't work. How can I solve this problem?
  • Why is this async function is running synchronously?
  • Get updated variable from within react hook before return
  • I want to show all image preview but whenever I upload a new one the old one is gone
  • Would I be able to give access to specific electron APIs safely?
  • Why several clicks fire for each instance of a Class?
  • cant grab value from div using attr()
  • Instantiate subclass without constructing
  • Outputing a created object in javascript to a server side JSON file
  • Transition the numeric labels in a bar chart
  • createBottomTabNavigator: hide just one tab from the tabBar
  • iife vs simple statement behavior with document.title
  • showDialogPopup Refresh Page after Click
  • Child component does not set the initial value passed from the parent: ReactJS
  • Nodejs javascript added to button not responding
  • Trying to define a promise.all
  • Python GEE to extract featurecollection timeseries from Landsat imageries
  • How to write negative binary number?
  • Unable to set property of individual object
  • Why Named Function Expression itself cannot assign Name to another Value?
  • How to reset scroll position on single page pagination
  • How to scroll to bottom of page, when a new message is sent - Socket.io
  • How to reconstruct audio blob from a base64 encoded String?
  • How to calculate numbers within an array of objects
  • Using JavaScript to change CSS properties of SVG circles for all circles that was not clicked
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org