issue with Jquery html text implementation for listbox control

19 views
Skip to first unread message

ranen biswas

unread,
Apr 27, 2017, 1:59:16 AM4/27/17
to Chromium-discuss
Hi,
I am working in web development and used jquery to implement wordwrap for HTMl listbox Item text.

$("#lstBox option[value='2']").html("html text is not working<br/> list item using with jquery ");

where I want to implement line break with <br/>. but in chrome it's not working. where Firefox it's working Perfect. 

Please let to know is there any resolution for chrome.

Regards,
Ranen

PhistucK

unread,
Apr 27, 2017, 2:34:26 AM4/27/17
to rane...@gmail.com, Chromium-discuss
I wonder whether Firefox behaves correctly... It only works with innerHTML, it does not work if it is in the HTML source.
So -
data:text/html,<!doctype html><select multiple><option>a<br/>b</option><option></option></select><script>document.querySelector("select").options[1].innerHTML="a<br/>b";</script>
(Or https://jsfiddle.net/04brr6gj/ if you prefer)
Will show -
ab
a
b

That seems inconsistent. And Firefox is the odd one out - all of the other browsers do not render line breaks, regardless of the method (innerHTML or HTML source).

I filed an HTML bug, though perhaps I should file Firefox bug.

My recommendation is not to use this feature, not even in Firefox, because you will (at the moment) not get a consistent behavior across browsers (and my guess is that you will not be able to use this feature in future Firefox).


PhistucK

--
--
Chromium Discussion mailing list: chromium...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

---
You received this message because you are subscribed to the Google Groups "Chromium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discuss+unsubscribe@chromium.org.

ranen biswas

unread,
Apr 27, 2017, 8:54:46 AM4/27/17
to PhistucK, Chromium-discuss
no hope with Innerhtml. I checked in jsfiddle. but if you open  https://jsfiddle.net/04brr6gj in firefox it's working exactly what I am looking for.

please let me know how can i overcome this in chrome. you can refer any alternate way to wordwrap long listitem text for html listbox control.

Regards,
Ranen

PhistucK

unread,
Apr 27, 2017, 9:01:04 AM4/27/17
to ranen biswas, Chromium-discuss
I was not suggesting a way to make other browsers render a line break in a <select multiple><option>.
I was suggesting that you implement this in another way (not using <select multiple><option>), because that is unlikely to ever work in non-Firefox browsers.
I do not think it is a bug, I think it is a bug that Firefox supports it.


PhistucK

ranen biswas

unread,
Apr 27, 2017, 9:15:23 AM4/27/17
to PhistucK, Chromium-discuss
I want to use multiple but want to display listitem into multiple line that is why I used below jquery 
HTML:

 <select id='lstBox1' style="width:240px;height:346px" multiple="multiple" >
 <option value="1" >ABCDEFGHIJKLMNOPQRSTUVWXYZ</option>
</select>

Jquery:

    $("#lstBox1 option[value='1']").innerHtml("ABCDEFGHIJKLMNOPQ<br/>RSTUVWXYZ");

Note:
So that it will display in listbox like: 
ABCDEFGHIJKLMNOPQ
RSTUVWXYZ

Regards,
Ranen
                                

PhistucK

unread,
Apr 27, 2017, 9:17:15 AM4/27/17
to ranen biswas, Chromium-discuss
Like I mentioned twice already, I understand and it is not possible.


PhistucK
Reply all
Reply to author
Forward
0 new messages