Replacing img src in textarea using jquery from a pop-up window
I'm trying to replace the textarea and input box image source in the parent window using jquery from a pop-up window. The text in the input box changes without any trouble, however the text in the textarea box remains unchanged.
Here's the code for the parent window:
- <textarea cols="100" rows="20" class="editor">
- <a href="http://www.amazon.com">
- <img src="image.jpg" alt="replace image source in this textbox" />
- </a>
- </textarea>
- <input type="text" value="image.jpg" maxlength="255" MultiLine="false" Class="inputBox" style="width:875px;" />
- <a href="/PopUpBox" class="popup">Click Here To Add An Image/s</a>
- <script type = "text/javascript">
- $('.popup').click(function (event) {
- event.preventDefault();
- window.open($(this).attr("href"), "popupWindow", "width=750, height=800, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes");
- });
- </script>
Here's the code for the pop-up window:
- <div class="selectButton">
- <input id="select" class="selectImage" type="button" data-imagepath="image2.jpg" value="Select">
- </div>
- <script type = "text/javascript">
- $('.selectImage').live("click", function (e) {
- var selectImage = $(this).data("imagepath");
- window.opener.$(".editor img").attr("src", selectImage); // can't change img src in textarea box
- window.opener.$(".inputBox").val(selectImage);
- self.close();
- e.preventDefault();
- });
- </script>
Any ideas why this isn't working?