www.webdeveloper.com
Results 1 to 2 of 2

Thread: what is this.id in different places

Hybrid View

  1. #1
    Join Date
    Sep 2012
    Posts
    3

    what is this.id in different places

    The meaning of this.id is self explanatory: element with currently focused on ID, but due to the abundance of the word "this", it is very difficult to find it in online js references, like w3schools.

    could someone post a link to the explanation of this id somewhere on the net?

    **

    It will help me deal with a specific problem.

    The problem is how to replace "this.id" with specific id reference. To narrow down my question, what does this.id refer to in the particular instances below and how could reference to it be made more directly, something like

    replacethisses="#particularID"
    ?

    Copy code

    Code:
    var itemlista1;
    var itemlista2;
    
    var mapa1 = { item1zest1 : itemlista1, item1zest2 : itemlista2 };
    
    $('#item1zest1, #item1zest2').change(function(){
    $("#wybierzitem1 option").remove();
    $.each(mapa1[this.id], function(i, val) {
    var opcja = $("<option />");
    chayn1 = val
    var cutted=chayn1.split("|");
    var singl=cutted.slice(0,1);
    opcja.appendTo($("#wybierzitem1")).text(singl);
    $('#wybierzitem1').trigger("change")
    });
    
    var versionesel = $("#wybierzitem1");
    var droplista = Math.floor(Math.random() * $('#wybierzitem1 option').length);
      versionesel.get(0).selectedIndex = droplista;
      versionesel.selectmenu('refresh', true);
    var itemwybrany = $('#wybierzitem1').val(); 
      
      versioneFOR1=(mapa1[this.id][droplista]); 
       
    $("label[for='itempick1'] .ui-btn-text").html(itemwybrany);
    });
    
    
    $('#wybierzitem1').change(function(){
      
    var itemwybrany = $('#wybierzitem1').val();   
    $("label[for='itempick1'] .ui-btn-text").html(itemwybrany);
    var itemwybrakowany = $('#wybierzitem1')[0].selectedIndex;

  2. #2
    Join Date
    Dec 2010
    Posts
    60
    Simply put, this applies to the element you are currently doing some action on. An example that helped me understand is if your getting elements by a tag name, the specific tag you are applying an action to

    Code:
    var links=document.getElementsByTagName('a');
    for(var i=0; i < links.length; i++){
    links[i].onclick=function(){
         this.style.border="1px solid red";
    }
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles