1

I have three product attributes named gross_weight,stone_weight & net_weight. While entering stone_weight the net_weight should be calculated using jquery. But jquery is not recognizing input field by its name. input field names are like name="product[net_weight]".

Please suggest any solution for this problem.

1 Answer 1

1

We can simply call with backslashes:

$('input[name="product\\[net_weight\\]"]')

enter image description here

To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \. For example, an element with id="foo.bar", can use the selector $("#foo\.bar")

We can see more here:

6
  • a big thanks for helping me. but i cannot able to trigger change or keyup events using the same logic Commented Dec 29, 2016 at 5:00
  • @ShiyasPathiyassery you should open new question. I will take a look. Commented Dec 29, 2016 at 5:01
  • Bro actually my question is really regarding the same issue. ie, event based on this element(s) not working properly so i cannot able to do anything with change or keyup events. Commented Dec 29, 2016 at 6:31
  • I think it is a different issue. I know your issue may related to UI component. You cannot bind the event to the elements? Commented Dec 29, 2016 at 6:34
  • Yes bro. That's what my actual problem. how to solve this problem Commented Dec 29, 2016 at 6:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.