dom-manipulation

Manipulating classes with jquery

♀尐吖头ヾ 提交于 2019-12-11 14:05:14
问题 I have a select box with values: apple-80 apple-100 apple-120 apple-300 I have: <body class="fruit apple-120 otherclass anotherclass"> I want to manipulate the body class "apple-120" to get replaced by any of selected value from the select box while keeping the fruit, otherclass, anotherclass, class untouched. So far I created this: $.fn.classSwitcher = function(options) { var baseOptions = { classTarget: 'body', oldClass: 'apple-120' }; var options = $.extend(baseOptions, options); return

How to Remove <a href> Link Tag for a Specific Value using Jquery

China☆狼群 提交于 2019-12-11 12:09:50
问题 I have the following situation within a report that has the following <td> element. Please note that this can appear multiples times as it is a report. My question is, when the value is ‘N’, using jQuery, I would like to remove the whole <a href> tag and just display the value of ‘N’ alone, without the underline below it, otherwise if the value is ‘Y’ then leave it as it is. For example: <td align="center" headers="MPA_CHANGED"><a href="http://www.mysite.com" class="my-mpa">Y</a></td> <td

How to wrap multiple instances of selected elements into new <div>'s

╄→гoц情女王★ 提交于 2019-12-11 08:12:38
问题 I need to wrap the div 's with the classes .left and .right into a new div . Having problems making this work as I need it to. This is the original markup: <div class="content-main"> <div class="summary" id="listing_summary_3547"> <div class="share"></div> <div class="left"></div> <div class="right"></div> </div> <div class="summary" id="listing_summary_12739"> <div class="share"></div> <div class="left"></div> <div class="right"></div> </div> <div class="summary" id="listing_summary_4"> <div

Unable to remove dynamically added content with jQuery

℡╲_俬逩灬. 提交于 2019-12-11 07:49:40
问题 I'm using jQuery to let users dynamically add and remove form fields, but it's not working properly. It works perfectly fine when removing the first field (which is hard-coded in the HTML mark-up), but it won't let me remove any of the fields that have been added dynamically. Here's my jQuery code: $("#addDog").click(function(event) { event.preventDefault(); var doglist = <?php echo "'" . $javadogs . "'"; ?>; var newdog = '<div><select name="resDog[]" class="select">' + doglist + '</select>

Detect outerHeight() of element with ng-repeat

北战南征 提交于 2019-12-11 01:59:07
问题 I'm trying to detect the height of an element that will change depending on data from a database. I have used .outerHeight successfully before but can't do this on an element that contains data from a ng-repeat. Is there a way to do this once the data has populated the angular element or is there another method of detecting this? 回答1: Yes, you need to create an attribute directive and put it on the ng-repeat. <div ng-repeat="whatever in items" outer-height></div> The directive will have a

How to automatically set the size of a drop-down list?

大兔子大兔子 提交于 2019-12-11 01:48:27
问题 I'm trying to write a script in Greasemonkey that will automatically set the size of Drop-down lists (there can be more than one...) on the number of selection options, but with my limited JavaScript knowledge I don't really know how to do this. Example of subject: <select name="z_pos_id"> <option value="2463">Option A</option> <option value="2609">Option B</option> <option value="3013">Option C</option> </select> <select name="z_pos_id"> <option value="140">Option AA</option> <option value=

jQuery empty() vs text('')

馋奶兔 提交于 2019-12-10 15:31:30
问题 Is there any different between $(element).empty() and $(element).text(''); Which one is better? 回答1: Result is the same, but if we look at jQuery text method implementation: text: function (value) { return jQuery.access(this, function (value) { return value === undefined ? jQuery.text(this) : this.empty().append((this[0] && this[0].ownerDocument || document).createTextNode(value)); }, null, value, arguments.length); }, we will see that $(element).text(''); will actually use .empty internally.

Reach Jekyll Variables With JavaScript and Pass it Throught DOM Manipulation

风格不统一 提交于 2019-12-10 15:08:18
问题 Highly possible that I have error logic but I'm just learning both JavaScript and Jekyll. My goal is to manipulate an HTML element through JavaScript and place some Jekyll variable inside the inner HTML of that element. Everything is loading from a local development directory with jekyll serve . I tried the following: HTML: <html> <body> <h2>Something</h2> </body> </html> JavaScript: document.addEventListener("DOMContentLoaded", function () { manipulate = document.getElementsByTagName("h2");

Insert after parent of element

試著忘記壹切 提交于 2019-12-10 04:41:58
问题 What sort of selector would be I need in order to insert after the parent (divouter) of the test3 class in the example below? Thanks. <div class='divouter'> <div class='divinner'> <input class=test1></input> </div> </div> <div class='divouter'> <div class='divinner'> <input class=test2></input> </div> </div> <div class='divouter'> <div class='divinner'> <input class=test3></input> </div> </div> <div class='divouter'> <div class='divinner'> <input class=test4></input> </div> </div> 回答1: You

jQuery - how to append multiple nodes to container

我怕爱的太早我们不能终老 提交于 2019-12-08 01:41:15
问题 I need to append multiple nodes to a container. Rather than doing a slow DOM append inside each iteration, I want to queue up the nodes in a document fragment (open to other ideas) and append them all at one time. Here is my code: var fragment = document.createDocumentFragment(); $.each( poFailureInfoMultiple, function(i,e){ fragment.appendChild( $('<button/>', { 'class': 'el-contents-center multiple-record' }) ); }); $('#some-container').html( fragment ); My problem is I am getting an error