logo
down
shadow

jQuery code to delete all spans with same content but keep one


jQuery code to delete all spans with same content but keep one

By : MrPeeps
Date : November 21 2020, 07:01 PM
Hope this helps Say i have the following html:
code :


Share : facebook icon twitter icon
Issue updating span content in a row of spans with jQuery by toggling contentEditable

Issue updating span content in a row of spans with jQuery by toggling contentEditable


By : Torg Dell
Date : March 29 2020, 07:55 AM
this one helps. I have a div which contains multiple spans. When a user clicks on the span, it should become editable. This part is working fine but when someone tries to edit the content in it, the problems begin. , use inline-block instead of inline-table
code :
span {
  width: 100px;
  display: inline-block;
}
Finding the closest spans id to replace the spans content

Finding the closest spans id to replace the spans content


By : gg3l
Date : March 29 2020, 07:55 AM
like below fixes the issue I'm provably over complicating this so stop me if I'm going down a rabbit hole. I'm trying to grab the id of a span when a checkbox is clicked and then change the content in that span. , Try this:
code :
$(this).closest(".check").find("span").text('Read');
How can i display inside a div the content of the spans in my code when i clic on them?

How can i display inside a div the content of the spans in my code when i clic on them?


By : ياسر حبه
Date : March 29 2020, 07:55 AM
will be helpful for those in need Here is one way to do it by adding an eventlistener to the document. Then we just get info from the target clicked. (Not all functionality is done yet in this example).
JS-FIDDLE
code :
//get number key values
var key = "";

document.addEventListener("click", function(e){

  switch (e.target.id) {
    case 'eq':
      calculate(key);
      return;

    case 'mult':
      key += "*";
      break;

    case 'dvd':
      key += "/";
      break;

    default:
    key += e.target.innerHTML;
    break;
  }
  document.getElementById('display').innerHTML = key;
});

//calculate result
function calculate(equation) {
    var answer = eval(equation);
    key = document.getElementById('display').innerHTML = answer;
}
Delete all the spans inside div on button click in jquery

Delete all the spans inside div on button click in jquery


By : Hui Gek
Date : March 29 2020, 07:55 AM
Any of those help So your code in question interprets - remove all spans when the delegated click event is targeted on .tagspans, so spans would be removed only when you click on spans
Try to use remove() :
code :
$(function(){
    $('#tags').on('click', function(){ 
        $(this).find('.tag').remove()
    });
});
#tags{
  background-color: green;
}
span{
  background-color: red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="tags">
  <span class='tag'>Span 1</span><br/>
  <span class='tag'>Span 2</span><br/>
  <span class='tag'>Span 3</span><br/>
  <span class='tag'>Span 4</span>
</div>
How to get clicked span inside div and modify its preceding spans and successor spans with JQuery?

How to get clicked span inside div and modify its preceding spans and successor spans with JQuery?


By : RMaas
Date : March 29 2020, 07:55 AM
To fix this issue To select all previous sibling elements of clicked element you can use prevAll() but to also include clicked element you need to add andSelf(). Also you first need to remove background from all span's every time you click on span.
code :
$('div span').click(function() {
  $('div span').css('background', 'none');
  $(this).prevAll().andSelf().css('background', 'red')
})
body {
  padding-top: 10px;
}
span {
  cursor: pointer;
  padding: 10px;
  border: 1px solid black;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
  <span>A</span>
  <span>B</span>
  <span>C</span>
  <span>D</span>
</div>
Related Posts Related Posts :
  • Javascript compiled or not? Check inside
  • Create a Count Up Timer in Javascript/Jquery
  • In Javascript, what's better than try/catch for exiting an outer scope?
  • Using JavaScript regex to strip substring that contains parentheses
  • jquery split() and indexOf results in "Object doesn't support this property or method"
  • ActionScript to Javascript cross-compiler
  • TinyMCE and pluploader not working together
  • Writing to a new window with javascript... get access denied
  • Differences between testing JavaScript and testing Ajax?
  • What JavaScript functions are supported by different browsers?
  • passing input text value to ajax call
  • Can JavaScript load raw bytes to use in HTML5 Canvas?
  • html form.input.value is not getting printed why?
  • A good way to redirect with a POST request?
  • Detect blocked pop-up in Chrome
  • javascript location.hash refreshing in IE
  • Sproutcore: adding a custom stylesheet or script
  • Display tabs like FireFox's on my website
  • JavaScript - get detailed information about the browser
  • Javascript mouse event not captured properly when mouse moved very fast
  • Large number array compression
  • Is it possible to use a string variable to reference an element in Javascript?
  • remove params from form request
  • How to prevent direct access to my JSON service?
  • Trigger Div Click From Link
  • JavaScript multithreading in IE6?
  • Variable scoping and the jQuery.getJSON() method
  • How can I Mimic Gmail's Basic HTML option
  • jQuery.ui.draggable.js and jQuery.ui.widget.js conflict
  • Row rendering in Qooxdoo
  • Google Maps: How does Trulia create their custom InfoWIndows?
  • How can I create an automatically generated alteranate table row color?
  • this fadeIn / fadeOut jQuery code crashes my browsers- Why?
  • call a server side python script from javascript
  • Code Colorer Being Used
  • dynamically create element using javascript
  • jQuery to check if returned data object is empty
  • JQuery hover problem
  • JavaScript Object Question
  • handling date for a mobile app using firebase as backend
  • Vuetify issue - why doesn't the v-img component display anything despite the image being passed in from a valid source?
  • How to sort an array with dynamic property?
  • Comparing property of an object in an array with another array
  • Resolve sibling folder in JavaScript Function
  • Simplify my jQuery code, which is growing huge and redundant
  • How to get row count for jqGrid?
  • Problem with Javascript object and accessing property which exists
  • JQuery: How to AutoComplete "City, State"?
  • javascript REGex remove single quote in match
  • How can I get the size of a file using JavaScript (preferably using MooTools 1.2)?
  • How to determine which date is on friday?
  • Generating thumbnails using jquery or javascript
  • Convert first letter of each word in a string to Uppercase in JavaScript
  • How to set background image of element to user uploaded image
  • How to keep the variable from returning to original value each time I use the onClick event
  • Using jsPDF to create a PDF from an iframe
  • Function Param not defined
  • What's so special about Monads in Kleisli category?
  • Some encoded Javascript that I need in plain text
  • How can I dynamically load and execute all of the Javascript files in a directory?
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk