Mohan Ram
Mohan Ram

Reputation: 8463

How to fetch the element inside tinymce using jquery?

How to fetch an element from getContent in tinymce using jquery

Upvotes: 1

Views: 255

Answers (1)

Thariama
Thariama

Reputation: 50832

You cannot fetch an element from ed.getContent() that easily. You would have to parse the javascript string in order to do so.

I assume you want to access the image tag you were reffering to in your other question. This can be easily done onClick:

ed.onClick.add(function(ed, evt){

    // Firefox
    if (evt.explicitOriginalTarget){
      if (evt.explicitOriginalTarget.nodeName.toLowerCase() == 'img'){
        console.log(evt.explicitOriginalTarget); // this is the img-element
      }
    }
    // IE
    else if (evt.target) {
      if (evt.target.nodeName.toLowerCase() == 'img'){
        console.log(evt.target); // this is the img-element
      }
    }
}

Upvotes: 1

Related Questions