skip to Main Content

Html –

<div class="pageEdit" value="Create|8765678|FOOD=6578~-8765678?|9381">
 <a href="https://host:controller">Edit</a>
</div>

I want to get the value inside the div and pass that in a Javascript method after splitting pipe.

$(".pageEdit").on('click',function(event){
            var data = $(".pageEdit").text().split("|");
            functionPageCreate(data(0),data(1),data(2),data(3));
    });

This is not working. I do not have much experience in JS/jQuery. Please let me know how can I do that.

2

Answers


  1. You can try below code:

    $(".pageEdit").on("click", function (event) {
      var data = $(".pageEdit").attr("value").split("|");
      functionPageCreate(data(0), data(1), data(2), data(3));
    });
    
    Login or Signup to reply.
  2. You should use another attribute to store data.

    <div class="pageEdit" data="Create|8765678|FOOD=6578~-8765678?|9381">
     <a href="https://host:controller">Edit</a>
    </div>
    

    Then retrieve it using

    $(".pageEdit").on("click", function (event) {
      var data = $(this).attr("data").split("|");
      functionPageCreate(data(0), data(1), data(2), data(3));
    });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search