How to make    ?

Asked

Viewed 2,845 times

3

I have a div that will serve as a menu.

The problem is I get these weird characters formatting the code and I didn’t put them there:     

These characters are not visible by the code, but are visible through the "Inspect Element" of the internet.

SS

I created this FIDDLE to show the error.

HTML/Jquery

<div id="menuOpt" data-theme="c" data-dismissible="false">
    <div data-role="header" class="ui-bar-b">
        <h1>Opções</h1>
    </div>
    <div role="main" class="ui-content" data-theme="b">
        <button type="button" class="ui-btn-b" ></button>
        <button type="button" class="ui-btn-b" ></button>
        <button type="button" class="ui-btn-b" ></button>
        <button type="button" class="ui-btn-b" ></button>
    </div>
</div>

JS referencing the menu

//atribuir largura ao menu das opçoes
$('#menuOpt').css({
   'width': nav_width + 'px',
// 'atributo':'Valor',
    });

    $("#menuOpt").slideToggle("slow");

Question

Why do these characters appear? How do I remove them?

  • I can’t reproduce. Here it’s right.

  • @Jorgeb. Don’t you see these characters? I’m using google Chrome. Can that be why? I’m finding it weird is that it’s the first time this comes to me and I have much more code

  • It is your Javascript that is creating the &nbsp;

  • @Jorgeb. how can Javascript be? These are the only references I make to this menu in JS $('#menuOpt').css({&#xA; 'width': nav_width + 'px',&#xA;// 'atributo':'Valor',&#xA; }); and $("#menuOpt").slideToggle("slow");. The rest is HTML and CSS

  • 2

    @Jorgeb. If you click to inspect element in that spacing between 4 divs you can see that in the HTML code. I think this is being implemented purposefully by the code JS to create these spacings, because if you look everywhere there are spacings that code is there.

  • You copied the code from your site/app and brought the &nbsp; with you. I keep saying it’s the JS you’re using.

  • 1

    http://jsfiddle.net/d38a9dhk/1/

  • @Jorgeb. this fiddle works well. But then I don’t understand why it’s the JS is doing this? But if the app step appears again the characters

  • Look at the JS you are using, you should have one that makes you add it. If you want to put the code.

  • 1

    Can you give more information? what application is this, what technology does it use

  • That’s all you have Javascript?

  • @Jorgeb. I passed your code once and it didn’t work after refreshing. I tried again, but this time I emptied the cache and made a heavy refresh and already worked and solved. but if I try to do with my code does not. Thank you very much and sorry for the confusion. I will use the fiddle you made available and change it to what I want :P

  • @msm.oliveira but solved the problem?

  • @Ricardo used Jorgeb. fiddle in my app and only after emptying the cache and doing a heavy refresh did it start working. With my code, it keeps popping up, but I’m gonna change the fiddle that Jorgeb made available to me. I want it. Sorry for the headaches I caused you, but thank you so much for your help

  • @Jorgeb. solved yes. I just still don’t understand how that piece of JS caused this

  • 1

    @msm.oliveira I don’t know if JS may have been your HTML editor, it may have been a lot.

  • The &nbsp; is a representation of white space. I did not understand what is the need to delete this, but you can simply delete the empty space and break the line again manually that these elements will disappear.

Show 12 more comments

3 answers

4


Could not play. It’s probably something Jsfiddle did and you shouldn’t worry about it. Note that you are inspecting a website that you have not done.

If it appears in another situation, it was she you should have posted.

Anyway this is no mistake. These characters are there for some reason and they are important. They represent a blank space. If you remove them you will have a different content.

If you haven’t put it on your page and it’s on it (which doesn’t seem to be the case), it won’t appear out of nowhere. Something is putting in and you have to analyze the whole to find out what you’re putting in. Still there must be a reason and removing these characters will bring problems. You have not put anything that can be said because they are being placed. Without more information, only you can find out why they are there.

Start doing things one step at a time to figure out what is putting this.

  • I didn’t post the site because this is an application and not a website. I can’t post the application here. But I copied exactly the code that I’m using the app on this menu. As I said in a comment on the question, I don’t understand why it might be in the JS if there I just reference that menu to assign a height and to make it appear/disappear

  • 1

    You’re wrong he copied the HTML from his code, if you delete the spaces between the buttons manually &nbsp; cease to appear.

  • Application or site, gives in it. The code you posted does not contain these characters.

  • @Jorgeb. exactly: "he copied the HTML from his code, if you delete the spaces between the buttons manually &nbsp; no longer appear"

  • @bigown see this then: http://jsfiddle.net/d38a9dhk/1/

  • 1

    The only thing I know is that nothing is placed without an agent doing this. The information is not matching. If he doesn’t show clearly where the problem is, it’s hard to help. We’re gonna be here kicking things. You have to create a way to reproduce the problem clearly.

Show 1 more comment

3

This character &nbsp; represents the character "space" (the same as if you press the space on the keyboard.) It is to be put by some of your javascripts. These sets of &nbsp; are harmless, Obs. they should be considered as a single character.

  • They’re harmless, but they’re changing the look of the app :P

  • Adding some spaces (like a character) this is not enough dangerous to the application.

  • But if it’s put by JS why in the FIDDLE, where I don’t use JS, I also get these characters?

  • there is yes: jQuery Mobile 1.3.0b1 (this checked this option) but the browser may also be inserted.

  • @The problem is that he copied the HTML and put it in the FIDDLE look: http://jsfiddle.net/d38a9dhk/1/

  • See the link I posted

  • I erased the &nbsp; of the code, that is, I joined the whole code (I erased everything that was between code) and the &nbsp; disappeared.

  • @No, I deleted it from the fiddle box, put all the code in one line and then gave the enter there.

Show 3 more comments

1

@Jorgeb. is right, you have copied this code, also brought the spaces &nbsp; together in Markup.

The problem is even in HTML code, if you rewrite the code line by line, or simply select the whole HTML text using keyboard shortcuts - ctrl + A and while the text is selected press shift + Tab (to rearrange the code and remove unnecessary spaces) and click run to run the code again in jsFiddle you will see that these spaces will disappear.

Here is an example in jsFiddle: http://jsfiddle.net/go35c5zy/
Follow the instructions in the window JavaScript

Browser other questions tagged

You are not signed in. Login or sign up in order to post.