How to remove input boxes

take a look at this fiddle.
If you click the edit icon a plus sign and a minus sign appear(forget the minus sign and focus on the plus)…if you click the plus sigh 2 times(for example) additional input boxes are added to the DOM…suppose that 2 or 3 are added,how can I remove specifically these 2 or 3? I know the last() and remove() methods,but here we are talking about a specific number of inputs for removal.

Can you please check the fiddle, possibly using an incognito account? No plus or minus sign appears in either Chrome or IE.
The images from livefilestore aren’t found.

That image fails to load (says the image contains errors) … (tip: add the required alt attribute, so it at least shows something on screen)

1 Like

you mean you don’t get to see this signs

Yes, we don’t get to see that. We don’t even get to see the Edit.

I have added the alt attributes but I do not know if these are clickable so you can actually see the behavior I am describing above-fiddle

We won’t be able to access them unless you add an alt attribute to the edit image as well.

see again:fiddle

P.S I am using jsfiddle for so long time and I have not still understand how you save.

btw, does var fieldsetCount = $('#serv').length; ever return anything other than 0?

the alt goes on the <img>, not the <div>!

hit the update icon in the top menu bar. (https://jsfiddle.net/q4uy6p44/52/)

If I understand you right, you want to remove several inputs at once. so what is the condition for the removal? if it’s all empty service inputs then do it similarly to what we did last time:

// pseudo-code
$(containers)
  .filter(empty services)
  .remove()
2 Likes

I am trying to implement the above code/solution: fiddle line 49(just click the edit button,add some input boxes and click cancel).
The problem is that the test for removing inputs is if they are empty(that is OK till now)…and the code proceeds removing the input box,the problem is that the input(s)-it is service input box and a price input box-are contained in a container(wrapper_servp)…so we must remove the container.

Test for the service input box if empty and remove the container.
The way the code is now this cannot be accomplished.

That’s not what I said in the pseudo code. It says there:

  • select all containers (that are possible subjects to removal)
  • select any of those containers, that have an empty service
  • remove the remaining containers (with the empty services)

Anyway…what I am starting to realize is that the input boxes must be removed either empty or not(I do not want to get into detail why this now).

So the goal now to remove specific number of inputs.
I tried this… see line 4.This code attempts to remove the container in which the input boxes are found…but it does not work

It seems the selector doesn’t match anything. Can’t tell if that’s a browser issue or a jQuery issue, though.

…and the problem is that I do not know how to debug it,the console in dev tools does not show anything at all.

Please supply a link to the most recent code that you’re having trouble debugging, and we can investigate to help give you the best course of action to take from there.

I have already done that,just check the fiddle link on post 14-the code that does not work is at line 4 in JS pane.

try this link in case you have(again) trouble viewing the images.

still not showing any images.

I have fixed the issue with the images-I changed hosting provider.
Tell me if you see them,just to be sure.

fiddle