JavaScript How to split html string to DOM elements? split html string c#,split html string javascript,split html

I have a html string

var str = '<span class="linq" onclick="ShowData(2,-1,1);">11111</span> &nbsp;»&nbsp; <span class="linq" onclick="ShowData(16,1,1);">22222</span> &nbsp;»&nbsp; 33333';

I need to split it to an array.

arr[0] = "<span class="linq" onclick="ShowData(2,-1,1);">11111</span>";
arr[1] = "&nbsp;»&nbsp;"
arr[2] = "<span class="linq" onclick="ShowData(16,1,1);">22222</span>";
arr[3] = "&nbsp;»&nbsp; 33333'"

I tried to use $.parseHTML() but i'm using jquery 1.6 and can't upgrade for now. If i use $(str) i get an array but without the last item.

arr[0] = "<span class="linq" onclick="ShowData(2,-1,1);">11111</span>";
arr[1] = "&nbsp;»&nbsp;"
arr[2] = "<span class="linq" onclick="ShowData(16,1,1);">22222</span>";
Answer:1

This is one way of doing it:

var temp = document.createElement('div');
temp.innerHTML = str;

var arr = Array.prototype.map.call(temp.childNodes, function(node) {
    return node.nodeType === 1 
         ? node.outerHTML
         : node.nodeValue;
});
Answer:2

That's dirty, but you can do something like

str = str + '<span></span>';

Now $str should return all the object you need plus an useless object, remember not to use the last object returned and you are ok

Answer:3

I have an Angular app where I'm using ui-grid. I want to have a custom action on a cell of the grid that calls a method from my app. So basically, this means calling a method that's somewhere up in ...

I have an Angular app where I'm using ui-grid. I want to have a custom action on a cell of the grid that calls a method from my app. So basically, this means calling a method that's somewhere up in ...

  1. angularjs call method on child component
  2. angularjs call method from another controller
  3. angularjs call method from html
  4. angularjs call method on page load
  5. angularjs call method on directive
  6. angularjs call method on child directive
  7. angularjs call method
  8. angularjs call method from another component
  9. angularjs call method on parent component
  10. angularjs call method from another directive
  11. angularjs call method inside directive
  12. angularjs call method from view
  13. angularjs call method on click
  14. angularjs call method from controller
  15. angularjs call method on component
  16. angularjs call method after ng-repeat
  17. angularjs call method from child controller
  18. angularjs call method on load
  19. angularjs call method in ng-repeat
  20. angularjs call method in constructor

I'm working with a form and would like to add ng-model on dynamic input elements. I have a scope variable defined as: $scope.formData = {}; On the page there are a couple of drop-down lists that ...

I'm working with a form and would like to add ng-model on dynamic input elements. I have a scope variable defined as: $scope.formData = {}; On the page there are a couple of drop-down lists that ...

  1. angularjs dynamic model name
  2. angularjs dynamic model value
  3. angularjs dynamic ng-model inside ng-repeat
  4. angularjs dynamic ng-model
  5. angularjs dynamic ng-model name
  6. angularjs get dynamic model value
  7. angularjs ng-model dynamic variable name
  8. angularjs ng-repeat dynamic model
  9. angularjs dynamic binding ng-model
  10. angularjs ng-model dynamic value
  11. angularjs dynamic input ng-model
  12. angularjs dynamic form ng-model

I want to pass a javascript variable to my servlet, where I need to use it. In javascript, the variable count returns the rows of my table and I can show count in the jsp, using $('#counter').html(...

I want to pass a javascript variable to my servlet, where I need to use it. In javascript, the variable count returns the rows of my table and I can show count in the jsp, using $('#counter').html(...

  1. access javascript variable in html
  2. access javascript variable in php
  3. access javascript variable in angular component
  4. access javascript variable in jsp
  5. access javascript variable in visualforce page
  6. access javascript variable from another file
  7. access javascript variable in typescript
  8. access javascript variable inside ajax success
  9. access javascript variable in c#
  10. access javascript variable in django template
  11. access javascript variable in java
  12. access javascript variable in css
  13. access javascript variable in python
  14. access javascript variable in mvc view
  15. access javascript variable in scriptlet
  16. access javascript variable in console
  17. access javascript variable in ejs
  18. access javascript variable in scss
  19. access javascript variable in jquery
  20. access javascript variable in classic asp

Can I set the biggest width and height without video cutting and page scrolling? <style> video { width: ?; height: ?; } </style>

Can I set the biggest width and height without video cutting and page scrolling? <style> video { width: ?; height: ?; } </style>

  1. 100 width height iframe
  2. 100 width height background image
  3. 100 width height div
  4. width 100 height auto
  5. width 100 height auto react native
  6. width 100 height proportional
  7. width 100 height
  8. width 100 height auto not working
  9. width 100 height square
  10. width 100 height 100vh
  11. 100(width) * 120(height) pixel
  12. textarea 100 width height
  13. 100 width and height css
  14. 100(width) * 120(height) pixels online
  15. svg 100 width height
  16. iframe width 100 height auto
  17. img width 100 height auto
  18. max-width 100 height auto
  19. background width 100 height auto
  20. image width 100 height auto