Trying to expand a list

Javascript has always confused me… I’d rather be coding in PHP… :slight_smile:
Anyway, can someone give me advice on how to have the
complete list of people expanded on page load without having to click expand?
Code is below…

<ul class="tree">
	<li>(<a href="javascript:;" rel="{{ affiliate_id }}"{% if top_count > 0 %} class="load_subs" title="{{ text_expand }}"{% endif %}>{{ top_count }}</a>)  <strong>{{ text_self }}</strong><img src="{{ image_loading }}" class="loading" style="display:none;" /></li>
</ul>
<script type="text/javascript"><!--
$(document).ready(function() {
	$(document).on('click', '.load_subs', function() {
		//$(this).attr('title', ($(this).attr('title') == '{{ text_expand }}' ? '{{ text_collapse }}' : '{{ text_expand }}'));
		var _p = $(this).parent();
		var _this = $(this);
		if($(_p).find('ul').length < 1) {
			$(_p).find('.loading').show();
			$.ajax({
				url: 'index.php?route=extension/module/mta/downline/l&affiliate_id='+$(_this).attr('rel'),
				dataType: 'json',
				success: function(_r) {
					$(_p).append('<ul></ul>');
					for(var i = 0; i < _r.length; i++) {
						var _li = '<li>(';
						if(_r[i].c > 0) _li += '<a href="javascript:;" class="load_subs" rel="'+_r[i].affiliate_id+'">';
						_li += _r[i].c;
						if(_r[i].c > 0) _li += '</a>'
						_li += ') <span class="aff_name">'+_r[i].name+'</span> ';
						
						{% if show.email %}
						_li += '<a href="mailto:'+_r[i].email+'" class="mailto-link">'+_r[i].email+'</a> ';
						{% endif %}						
						{% if show.phone %}
						_li += ' '+_r[i].telephone+' ';
						{% endif %}						
						_li += ' <img src="{{ image_loading }}" class="loading" style="display:none;" />';
						
						{% if show.earnings %}
						_li += '<span class="help">';
						_li += '{{ text_abbr_te }}: ' + _r[i].e_te + ' / ' + '{{ text_abbr_elm }}: ' + _r[i].e_elm;
						_li += '</span>';
						{% endif %}
						_li += ' </li>';
						$(_p).find('ul').append(_li);
					}
					$(_p).find('.loading').hide();
				}
				});
		} else {
			$($(_p).find('ul')[0]).toggle();
		}
	});
	if($('.load_subs').length > 0) $('.load_subs').trigger('click');
}
);

//--></script>

what code is this?

what languages are you using? I am confused

Hi @musicweb

The code in the script element is nested in a comment element, so the browser will ignore it.

However, it doesn’t look like JavaScript.

Happy coding

hey ,i think these codes are from the developer control tools of the browser and have been processed. you can show javascript from the IDEA (vscode,webstorm … ).
happy coding

Sorry, the code is actually nested in a twig template, so some texts are enclosed in {{ }}