by ian2000 May 15th 2015, 12:04 am
This is super helpful
@Ange Tuteur! Exactly what I needed help with! Your code works perfectly.
However I'm having trouble understanding something. I have some a piece in my HTML:
- Code:
<p>I want <b id="test">THIS</b> to change</p>
And I slightly modified your code, only replacing one of your alerts with:
- Code:
document.getElementById('test').innerHTML = "ABC"
And the result is:
- Code:
<script type="text/javascript">// <![CDATA[
(function($) {
 $.get('/groups', function(d) {
  if ($('a[href*="/g1-"]', d)[0]) document.getElementById('test').innerHTML = "ABC";
  else if ($('a[href*="/g2-"]', d)[0]) alert('MOD');
  else alert('MEMBER');
 });
})(jQuery);
// ]]></script>
Could you help me figure out why I can't get this to work though? If I'm thinking about this correctly, I should get the "THIS" to change to "ABC"
only if the user is an admin... But nothing happens.Â
"MOD" and "MEMBER" are still alerted as normal, though so thanks for that!
Last edited by ian2000 on May 15th 2015, 9:58 am; edited 1 time in total