how to remove particular substring from string using id of li in jquery

Kaustubh Bhujbal

I have string

0=>zxz##5=>zxzx##5=>zxz##10=>zxz##1=>asdasd##12=>asdsad##10=>asdsad

where 0,5,10 are ids, text are values and ## is delimiter.

I have id and i want to remove id's value

This is my following code, Please check and suggest.

code1

function remove_feature(id)
{
    var feature_str  = $("#features_post").val();
    var feature_string = feature_str.replace(['id=feature_str'],'', 'gi');  
    window.jQuery("#features_post").val(feature_string); 
    window.jQuery("#"+id+"").remove();
      alert(feature_string);
    return true;
}

code2

 function remove_feature(id)
{
    var feature_str  = $("#features_post").val();
    var feature_string = feature_str.replace(id,'', 'gi');  
    window.jQuery("#features_post").val(feature_string); 
     window.jQuery("#"+id+"").remove();
    alert(feature_string);
        return true;
    }

I have tried both of code but not working

Giannis Grivas

Try this one with jquery : http://jsfiddle.net/h0qtxn7d/ Can also remove same multiple ids.

var k = "0=>zxz##5=>zxzx##5=>zxz##10=>zxz##1=>asdasd##12=>asdsad##10=>asdsad";
var obj = k.split("##");
var removeItem = 5;

alert('Array before removing the element = ' + obj)
obj = jQuery.grep(obj, function(value) {
  return value.split('=>')[0] != removeItem;
});

alert('Array after removing the element = ' + obj);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to remove and ID from a string

From Dev

Getting a substring from a string after a particular word

From Dev

How to remove a particular character from an entire row of a particular string using perl regex?

From Dev

How to remove string from string until a specefic character using jquery

From Dev

How to hide particular li using jquery

From Dev

How can I remove spaces from a string? only using indexOf() and substring()

From Dev

Remove substring from string in D

From Dev

How remove a specific string from an element's text using jQuery?

From Dev

How to remove DateTime substring from string

From Dev

How to remove substring from the end of the string

From Dev

How to remove particular same string from string

From Dev

How to remove a particular character from an entire row of a particular string using perl regex?

From Dev

How to remove substring from string in javascript?

From Dev

How to remove empty comma from string using JQuery

From Dev

How to hide particular li using jquery

From Dev

How to remove substring from a string in python?

From Dev

Getting an id from a ul li using jquery

From Dev

how to remove particular substring from string using id of li in jquery

From Dev

How to extract substring from a string using regex?

From Dev

How to update a row with a substring of a string in that particular row?

From Dev

Remove string from a particular field using awk/sed

From Dev

How to remove particular path from google map using jquery

From Dev

How to remove substring from the end of the string

From Dev

How to remove a substring from a string using a template function?

From Dev

Remove li from ul using id of li

From Dev

Remove a substring from String

From Dev

Remove particular string from url Jquery

From Dev

how to extract a particular substring from a string in python

From Dev

Using String.format to remove particular digits from an integer

Related Related

  1. 1

    How to remove and ID from a string

  2. 2

    Getting a substring from a string after a particular word

  3. 3

    How to remove a particular character from an entire row of a particular string using perl regex?

  4. 4

    How to remove string from string until a specefic character using jquery

  5. 5

    How to hide particular li using jquery

  6. 6

    How can I remove spaces from a string? only using indexOf() and substring()

  7. 7

    Remove substring from string in D

  8. 8

    How remove a specific string from an element's text using jQuery?

  9. 9

    How to remove DateTime substring from string

  10. 10

    How to remove substring from the end of the string

  11. 11

    How to remove particular same string from string

  12. 12

    How to remove a particular character from an entire row of a particular string using perl regex?

  13. 13

    How to remove substring from string in javascript?

  14. 14

    How to remove empty comma from string using JQuery

  15. 15

    How to hide particular li using jquery

  16. 16

    How to remove substring from a string in python?

  17. 17

    Getting an id from a ul li using jquery

  18. 18

    how to remove particular substring from string using id of li in jquery

  19. 19

    How to extract substring from a string using regex?

  20. 20

    How to update a row with a substring of a string in that particular row?

  21. 21

    Remove string from a particular field using awk/sed

  22. 22

    How to remove particular path from google map using jquery

  23. 23

    How to remove substring from the end of the string

  24. 24

    How to remove a substring from a string using a template function?

  25. 25

    Remove li from ul using id of li

  26. 26

    Remove a substring from String

  27. 27

    Remove particular string from url Jquery

  28. 28

    how to extract a particular substring from a string in python

  29. 29

    Using String.format to remove particular digits from an integer

HotTag

Archive