javascript - JQuery .text() method outputting garbled text -


so i've been having strange issue jquery's .text() method. have right js code generates random phrase few banks of random words, believe has no problem (it produces string). when click link in browser, link's text replaced random phrase produced random phrase generator. far, there nothing wrong generated random phrase. however, tends garble text behind it:

garbled text

it seems browser having difficulty when pushing text next line, causing overlap text there. when highlight paragraph, "resets" correctly , it's fine until try clicking link again. if zoom in or out, seems it's fine until return 100% zoom. if make text font size smaller, seems work fine too.

here javascript code:

//initially random phrase , display on page getrandomphrase(); $('#phrase').text(finalphrase.new);  //on click, random phrase , display on page $('#phrase').click(function () {     getrandomphrase();     $('#phrase').text(finalphrase.new); }); 

here html tag i'm trying replace:

<a title="click!" href="#about" id="phrase">(the random phrase should in here)</a> 

the tag in middle of paragraph of text. if has idea how fix great!

edit: here's of css, don't know problem be. i'm using on top of bootstrap:

@import url(http://fonts.googleapis.com/css?family=roboto); @import url(http://fonts.googleapis.com/css?family=roboto+slab); body {     font-family: 'roboto', sans-serif;     background-color: #fff7e4;     font-size: 14px; }  h1 {}  hr {     border-color: #9a9a9a; }  #name {     font-family: 'roboto slab', serif;     margin-top: 0px;     font-size: 80px;     color: #db1c00; }  #header {     font-size: 20px;     color: white;     padding-top: 70px;     padding-bottom: 40px;     background-color: #ccc6a6; }  #about {     font-size: 20px; }  #phrase {     color: #db1c00; } 

i've managed fix problem. solution strange, though. should've added more html original post.

here basic view of frontend html:

<div id="about">blah blah blah me stuff      <a title="click!" href="#about" id="phrase">(the random phrase should in here)</a> </div> 

i had sent link in tag go #about, did not seem wrong @ all. (the reason did because user needed able click on link , stay there see result). changed href #phrase, linking link itself:

<div id="about">blah blah blah me stuff      <a title="click!" href="#phrase" id="phrase">(the random phrase should in here)</a> </div> 

this fixed whole garbled text issue somehow. hypothesis linking entire div somehow not allowing reset properly, or caching div's original content in way. anyways, if explain why works great haha. if has explanation, please let me know! it's weird solution , have no idea why works (or why there problem in first place!


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -