Bevor
Bevor

Reputation: 8605

jQuery add content to element without id

I want to add text to a rich:editor inside the <p>...</p> elements by using jQuery. The HTML looks like this:

enter image description here

How can I add text by using this command (I need to modify existing code).

jQuery("????????????").text(data.dataMap["error.message"]);

Upvotes: 1

Views: 61

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1075209

If it's the only paragraph containing a br with type="_moz", then the selector is p:has(br[type=_moz]) (a type selector with jQuery's :has combinator, with a type selector combined with an attribute value selector inside).

Or of course, it's the first paragraph in the body, so body p:first or body p:eq(0).

Otherwise, you'll have to find other aspects about it that let you target it uniquely (other attributes, where it is, what comes before, what comes after, what it has in it, etc.).

Upvotes: 2

Related Questions