Important Update: Some Community URL Redirects are Under Maintenance. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Custom Object

Ajeet
Contributor III

in case of span id i created something like this which is working fine.

document.querySelector('#span_id').onclick =
function()
{
alert();
}

5 REPLIES 5

DavidPetty
Archer Employee
Archer Employee

Or,

$('#span_id').click(function(){
     alert();
});

 Advisory Consultant

thank you @DavidPetty  but my ask is if there is no span id how it would be in that case.

element is something like this with out span id

<div class="readonly">

<span>test</span>

</div>

Ajeet_0-1629374859320.png

 

That gets a little trickier.  You'd have to find an element that has an id or unique class and go from there.

 Advisory Consultant

Ajeet
Contributor III

I have thoroughly inspected html tree in view and edit mode and found that only table id and table td class is same in both of the cases so i would need to use table id and td class to add click event.

this is not working:

        var field = $CM.getFieldById($CFS.CONTENT.getFieldId('Name_Demo'));
        var element = $LM.getFieldElement(field);
        (element).closest('td').find('.tdClass').onclick =
            function () {
                alert("onclick");
            } 
 
the following code is working but it is working for whole table element.
 
$('#tableID tr').click(function() {
        alert("working");
        copyText(element);
    });
 
iam looking for a code which will work on a particular table td class. is there any specific syntax? @DavidPetty @Ilya_Khen @Ilya.Khen @Jay  i can not use span id because in edit mode it is span tag only.

@Ajeet 

You might be able to supply the index of .tdClass like below by putting the index number inside of the brackets.

(element).closest('td').find('.tdClass')[2].onclick =
     function () {
          alert("onclick");
     } 

 

 Advisory Consultant