Bug Tracker


Ticket #5316 (closed bug: fixed)

Opened 5 years ago

Last modified 3 years ago

replaceAll only the first element from the matched set replaces the selector set

Reported by: TUSHKA Owned by:
Priority: high Milestone: 1.4.3
Component: manipulation Version: 1.4.2
Keywords: Cc:
Blocking: Blocked by:


var jq = $("<selector1>") selects more than one element jq.replaceAll("<selector2>")

only the first matched element from jq will show up as the replacement for "<selector2>"

Possible Fix: See Attachment


jquery.txt Download (861 bytes) - added by TUSHKA 5 years ago.
Possible Fix
jquery-replaceall-testcase.html Download (1.6 KB) - added by Perceptes 4 years ago.
A test case to show the issue, run it in a browser to see what's happening.

Change History

Changed 5 years ago by TUSHKA

Possible Fix

comment:1 Changed 5 years ago by TUSHKA

Possible fix, invoke replaceWith using call rather than apply. This will affect appendTo/append, prependTo/prepend, insertBefore/before, insertAfter/after as well, but it seems like those will work regardless of whether they are invoked via call or apply

comment:2 Changed 4 years ago by Troanis


My workaround until fixed jq.wrap('<div/>').parent().replaceAll("<selector2>").replaceWith(jq)

Changed 4 years ago by Perceptes

A test case to show the issue, run it in a browser to see what's happening.

comment:3 Changed 3 years ago by jitter

  • Status changed from new to closed
  • Component changed from core to manipulation
  • Priority changed from minor to high
  • Version changed from 1.3.2 to 1.4.2
  • Milestone changed from 1.4 to 1.4.3
  • Resolution set to fixed

 test case fixed for 1.4.3

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.


Add a comment

Modify Ticket

as closed

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.